WIPIVERSE All articles

Fast approximate anti-aliasing

Fast approximate anti-aliasing (FXAA) is a screen-space anti-aliasing algorithm created by Timothy Lottes at Nvidia. It is a post-processing technique that operates on the rendered image rather than analyzing the underlying 3D geometry.

Algorithm description

The FXAA algorithm processes a rendered image as follows:

  1. The input data is the rendered image and optionally the luminance data. Luminance may be passed into the algorithm as an alpha channel embedded in the image, calculated from the rendered image, or approximated by using the green channel.
  2. High-contrast pixels are identified using a high-pass filter applied to the luminance data. Low-contrast pixels are excluded from further modification. The filter can be tuned to balance speed and sensitivity.
  3. Contrast between adjacent pixels is used heuristically to detect edges and determine their orientation (horizontal or vertical). The blend direction of a pixel is perpendicular to the detected edge direction at that pixel.
  4. A blend factor is calculated by analyzing luminance data in a 3×3 pixel grid centered on the pixel in question.
  5. A search is performed along the detected edge to determine its length and the direction the actual edge takes once a detected horizontal or vertical edge ends, producing a second blend factor. This step can be tuned for more quality (increasing search resolution and distance) or more speed.
  6. The pixel is blended using the chosen blend direction and the maximum of the two calculated blend factors.

Comparison with other anti-aliasing methods

The main advantage of FXAA over conventional spatial anti-aliasing is its low computational cost. It smooths undesirable jagged edges ("jaggies") based on how pixels appear on screen rather than analyzing the 3D model itself. Because it is not geometry-based, it also smooths edges inside alpha-blended textures and those resulting from pixel shader effects, which are not addressed by multisample anti-aliasing (MSAA).

The downsides include:

  • High-contrast texture maps can be blurred, an effect that can be reduced by adjusting "subpix filtering."
  • FXAA must be applied before rendering HUD elements of a game to avoid affecting them.
  • Polygonal details smaller than one pixel that would be captured by MSAA or supersample anti-aliasing (SSAA) cannot be captured by FXAA alone.

FXAA includes a sub-pixel low-pass filter pass designed to reduce shimmering and aliasing in shader results such as shadows and specular highlights.

Licensing

FXAA 3 is released under a public domain license. A later version, FXAA 3.11, is released under a 3-clause BSD license.

FXAA is widely used in real-time computer graphics applications, particularly in deferred rendering pipelines that lack hardware MSAA support, and can also be combined with hardware anti-aliasing to smooth hard edges missed by MSAA.

Browse

More topics to explore

    Browse all articles