FXAA
A single-pass post filter that finds edges from luma contrast, estimates their orientation and blends pixels along the edge normal; cheap and shader-only, but it also softens interior texture detail.
Also known as Fast Approximate Anti-Aliasing
In the family Post-processing, color & imaging, anti-aliasing
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { fxaa } from 'three/addons/tsl/display/FXAANode.js' (WebGL: FXAAPass) docs |
| Babylon.js 9.38.0 | Built in | pipeline.fxaaEnabled = true (DefaultRenderingPipeline) or new BABYLON.FxaaPostProcess docs |
| Godot 4.7 | Built in | Viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_FXAA docs |
| Unity | Built in | URP: Camera > Rendering > Anti-aliasing = Fast Approximate Anti-aliasing (FXAA) docs URP and HDRP. |
| Unreal 5.7 | Built in | Project Settings > Rendering > Default Settings > Anti-Aliasing Method = FXAA docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
FXAA runs on the final LDR image with no depth or geometry. It computes luma for a pixel and its four neighbours, skips the pixel if local contrast is below a threshold, then classifies the edge as horizontal or vertical from second-derivative-like sums over the 3x3 neighbourhood. It moves half a pixel toward the stronger gradient side, searches along the edge in both directions until the luma profile departs from the edge average, and uses the endpoints to compute a subpixel offset. The final sample is a bilinear fetch shifted perpendicular to the edge, which blends the edge with the other side. A separate subpixel-aliasing term lowpasses isolated bright pixels. Quality presets differ in the length of the edge search.
When to choose it
Reach for it when
- jagged edges but no budget for heavy antialiasing
- mobile or webgl needs the cheapest edge smoothing
- msaa isn't available in my deferred pipeline
- need quick post-process edge softening
Choose it when you need the cheapest possible AA on mobile or WebGL, or as a fallback for forward-rendered scenes without motion vectors.
Prefer SMAA when you can afford three passes and want sharper results with proper corner handling. Prefer Temporal Anti-Aliasing when shading aliasing and subpixel detail dominate and motion vectors exist.
Field marks
- Global softening of text and fine textures because it cannot distinguish edges from detail
- Rounded corners and wobbly near-horizontal lines from the heuristic edge search
- No help with subpixel geometry or temporal shimmer
- Must run after tonemapping, otherwise HDR highlights alias unfiltered
Presets
Left: aliased frame. Right: FXAA, luma-gradient direction and two blurred taps along the edge
{
"DREDMUL": 0.125,
"DREDMIN": 0.0078
}Show GLSL (33 lines)
float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}
vec3 scnA(vec2 px){vec2 p=(px-256.)/512.;
vec3 c=vec3(.93,.92,.88);
float s=fract((p.x*.866+p.y*.5)*11.);c=mix(c,vec3(.1,.12,.2),step(s,.18)*step(abs(p.y+p.x*.3),.38));
float d=length(p-vec2(.0,.0));c=mix(c,vec3(.85,.25,.2),step(abs(d-.2),.02));
c=mix(c,vec3(.1,.5,.4),step(length(p-vec2(-.25,.28)),.1));
c=mix(c,vec3(.1),step(abs(p.x-.2),.004)*step(abs(p.y-.1),.3));
return c;}
const float DREDMUL=0.125; // P
const float DREDMIN=0.0078; // P
vec3 T(vec2 f){return scnA(floor(f)+.5);}
vec3 Tb(vec2 f){vec2 g=f-.5,i=floor(g),w=g-i;
return mix(mix(T(i+.5),T(i+vec2(1.5,.5)),w.x),mix(T(i+vec2(.5,1.5)),T(i+1.5),w.x),w.y);}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);
vec3 col=T(fragCoord);
if(R){
vec2 f=floor(fragCoord)+.5;
vec3 nw=T(f+vec2(-1.,-1.)),ne=T(f+vec2(1.,-1.)),sw=T(f+vec2(-1.,1.)),se=T(f+vec2(1.,1.)),m=T(f);
float a=lum(nw),b=lum(ne),c=lum(sw),d=lum(se),e=lum(m);
float lo=min(e,min(min(a,b),min(c,d))),hi=max(e,max(max(a,b),max(c,d)));
vec2 dir=vec2(-((a+b)-(c+d)),(a+c)-(b+d));
float red=max((a+b+c+d)*.25*DREDMUL,DREDMIN);
dir=clamp(dir/(min(abs(dir.x),abs(dir.y))+red),-8.,8.);
vec3 r1=.5*(Tb(f+dir*(1./3.-.5))+Tb(f+dir*(2./3.-.5)));
vec3 r2=r1*.5+.25*(Tb(f-dir*.5)+Tb(f+dir*.5));
float lb=lum(r2);col=(lb<lo||lb>hi)?r1:r2;
}
if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);
}Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| fxaa-specimen | Tesla T4 1920x1080 | 11.4× baseline (moderate) · 0.376 ms / 0.390 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| fxaa-specimen | NVIDIA L4 1920x1080 | 8.51× baseline (moderate) · 0.135 ms / 0.137 ms · 2.8× faster on L4 | opengl-timer-query · Cross-architecture validation |
| fxaa-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 7.82× baseline (moderate) · 0.225 ms / 0.226 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Temporal Anti-Aliasing: FXAA can clean up the output of a TAA resolve on frames where history was rejected.