Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

fxaa

The render pass behind the EdgeAntiAliasing component and the antiAliasing module.

One compute pass after lighting. For each pixel it decides whether it sits on an edge, works out which way that edge runs, walks along it to find where it ends, and shifts its sample across the edge by however far along it the pixel sits.

The result is not a blur. A blur softens everything; this moves each edge pixel's sample perpendicular to the edge by a sub-pixel amount, so the step between two flat regions becomes a gradient while both regions are left as they were. That is why the pass has to find the edge's direction and extent rather than filtering a neighbourhood: the offset depends on where along the edge the pixel falls.

Detection. Luminance across the four direct neighbours gives the local range. Below the threshold the pixel is passed through untouched. The absolute floor under that test is what keeps the pass off dark areas, where a small relative step is still visually flat. Luminance drives every decision because the eye resolves luminance detail far more finely than chroma — a step that reads as a jagged edge is a step in luminance, and an edge that is pure chroma needs no correction.

Orientation. The 3x3 luminance neighbourhood gives two second-derivative sums, one per axis. The larger names the axis the luminance changes across, so an edge running left-to-right shows its variation vertically.

The walk. The pass steps half a texel onto the edge itself, then walks in both directions until the luminance stops matching the boundary's. How far each end lies decides how far this pixel's sample shifts. The correction applies only when the pixel is on the darker side of the nearer end — otherwise the shift would pull the edge the wrong way and sharpen the step instead of smoothing it.

Sub-pixel features. A feature finer than one pixel produces no long edge to walk, so the 3x3 average carries the correction instead. Without it a lone bright pixel keeps its hard corners.

The final sample lands between texels and is fetched by hand — the pass reads the scene by exact texel and has no sampler of its own.

Parameters arrive through the fxaa_params buffer, packed by the antiAliasing module.