SMAA
Morphological anti-aliasing in three passes: detect edges, compute per-pixel blending weights from pattern area lookups, then blend neighbours. Sharper than FXAA and with optional temporal and MSAA extensions.
Also known as Subpixel Morphological 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 { smaa } from 'three/addons/tsl/display/SMAANode.js' (WebGL: SMAAPass) docs |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | Viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_SMAA docs |
| Unity | Built in | Camera > Rendering > Anti-aliasing = Subpixel Morphological Anti-aliasing (SMAA) docs URP and HDRP. |
| Unreal 5.7 | None found | Unreal ships TSR, TAA, FXAA, and MSAA rather than SMAA. |
| Blender 5.2 | Built in | Preferences > Viewport > Quality > Viewport Anti-Aliasing (morphological screen-space AA) docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
SMAA first detects edges from luma, colour or depth deltas, using local contrast adaptation to suppress false positives near strong edges. The second pass is the core: for every edge pixel it searches along the edge in both directions to find its endpoints, reads the crossing edges at each end to classify the line shape (L, Z, U), and looks the coverage up in a precomputed area texture. A separate search texture accelerates the walk. The output is a four-channel weight buffer. The third pass blends each pixel with its neighbours according to those weights, using bilinear taps to apply two blends in one fetch. Variants add diagonal pattern detection, corner rounding and a 2x temporal mode.
When to choose it
Reach for it when
- jagged edges without heavy msaa cost
- post process anti aliasing that stays sharp
- fxaa blurs the whole image too much
- deferred renderer can't use hardware msaa
Choose it when you want clean geometric edges at modest cost and no motion vectors.
Prefer FXAA when you must stay in a single pass. Prefer Temporal Anti-Aliasing when shading and subpixel aliasing matter more than edge shape. SMAA T2x gives a taste of temporal supersampling if you have jitter and velocity.
Field marks
- Cannot reconstruct subpixel features thinner than a pixel
- Shading aliasing and specular crawl are untouched
- Edge detection thresholds need tuning per content; noisy scenes produce spurious blur
- Needs a render target format that preserves the weight buffer, and three passes cost bandwidth on mobile
Presets
SMAA — aliased 1x raster edges (left) vs morphological L/Z/U edge search & subpixel coverage blending (right)
{
"P_PIXEL_SIZE": 3.5,
"P_EDGE_THRESH": 0.12,
"P_EDGE_DEBUG": 0.25,
"P_SPLIT": 0.48
}Show GLSL (144 lines)
const float P_PIXEL_SIZE = 3.50; // P Raster Pixel Zoom [1.5, 7.0, 0.25]
const float P_EDGE_THRESH = 0.12; // P Edge Threshold [0.04, 0.35, 0.02]
const float P_EDGE_DEBUG = 0.25; // P Edge Overlay [0.0, 1.0, 0.05]
const float P_SPLIT = 0.48; // P Aliased / SMAA [0.0, 1.0, 0.02]
vec2 rot2(vec2 p, float a) {
float c = cos(a);
float s = sin(a);
return vec2(c * p.x - s * p.y, s * p.x + c * p.y);
}
// Sharp high-contrast geometric blades & polygons that produce classic 1x stair-step jaggies
vec3 evalAliased(vec2 uv, float t) {
vec3 col = mix(vec3(0.07, 0.10, 0.16), vec3(0.16, 0.24, 0.36), smoothstep(-0.5, 0.5, uv.y));
vec2 p = rot2(uv, 0.18 * sin(t * 0.45) + 0.12);
// Sharp tilted white & orange architectural monoliths
vec2 b1 = abs(p - vec2(-0.18, 0.02)) - vec2(0.24, 0.34);
if (max(b1.x, b1.y) < 0.0) {
col = mix(vec3(0.86, 0.89, 0.94), vec3(0.68, 0.74, 0.84), smoothstep(-0.3, 0.3, p.y));
}
vec2 p2 = rot2(uv - vec2(0.14, -0.04), -0.34 + 0.10 * cos(t * 0.5));
vec2 b2 = abs(p2) - vec2(0.26, 0.18);
if (max(b2.x, b2.y) < 0.0) {
col = vec3(0.95, 0.44, 0.16);
}
// Crisp diagonal cyan blade cutting across both shapes
vec2 p3 = rot2(uv, 0.28);
if (abs(p3.y - 0.05) < 0.048 && abs(p3.x) < 0.55) {
col = vec3(0.14, 0.86, 0.96);
}
// Fine circular ring with high-contrast boundary
float rc = length(uv - vec2(0.02, 0.02));
if (abs(rc - 0.28) < 0.024) {
col = vec3(0.10, 0.12, 0.18);
}
return col;
}
vec3 fetchPx(vec2 cellCoord, float cell, float t) {
vec2 fc = (cellCoord + 0.5) * cell;
vec2 uv = (fc - 0.5 * iResolution.xy) / iResolution.y;
return evalAliased(uv, t);
}
float luma(vec3 c) {
return dot(c, vec3(0.299, 0.587, 0.114));
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
float cell = clamp(P_PIXEL_SIZE, 1.2, 8.0);
float thresh = clamp(P_EDGE_THRESH, 0.03, 0.4);
float dbg = clamp(P_EDGE_DEBUG, 0.0, 1.0);
vec2 pix = floor(fragCoord / cell);
vec3 cC = fetchPx(pix, cell, iTime);
vec3 cL = fetchPx(pix + vec2(-1.0, 0.0), cell, iTime);
vec3 cR = fetchPx(pix + vec2(1.0, 0.0), cell, iTime);
vec3 cD = fetchPx(pix + vec2(0.0, -1.0), cell, iTime);
vec3 cU = fetchPx(pix + vec2(0.0, 1.0), cell, iTime);
// Pass 1: Local-contrast-adapted luma edge detection
float lC = luma(cC);
float dH = max(abs(lC - luma(cD)), abs(lC - luma(cU)));
float dV = max(abs(lC - luma(cL)), abs(lC - luma(cR)));
float edgeH = step(thresh, dH);
float edgeV = step(thresh, dV);
vec3 col = cC;
if (screenX < split) {
// Left: Raw 1x aliased pixels + optional SMAA Pass-1 edge detection highlight (red=horiz, green=vert)
vec3 edgeTint = vec3(edgeH, edgeV, 0.0);
col = mix(cC, edgeTint * 1.25, dbg * clamp(edgeH + edgeV, 0.0, 1.0) * 0.65);
} else {
// Right: Pass 2 & 3 -- Search along horizontal/vertical span to measure stair-step run length & blend coverage!
vec3 blended = cC;
if (edgeH > 0.5) {
float spanL = 0.0;
float spanR = 0.0;
float upSide = step(abs(lC - luma(cD)), abs(lC - luma(cU)));
float dirY = (upSide > 0.5) ? 1.0 : -1.0;
for (int s = 1; s <= 6; s++) {
float fs = float(s);
float l1 = luma(fetchPx(pix + vec2(-fs, 0.0), cell, iTime));
float l2 = luma(fetchPx(pix + vec2(-fs, dirY), cell, iTime));
if (abs(l1 - l2) < thresh) break;
spanL = fs;
}
for (int s = 1; s <= 6; s++) {
float fs = float(s);
float l1 = luma(fetchPx(pix + vec2(fs, 0.0), cell, iTime));
float l2 = luma(fetchPx(pix + vec2(fs, dirY), cell, iTime));
if (abs(l1 - l2) < thresh) break;
spanR = fs;
}
float totalSpan = max(spanL + spanR + 1.0, 1.0);
float posAlong = (spanL + 0.5) / totalSpan;
// Trapezoidal area coverage lookup approximation for L/Z crossing patterns
float cov = clamp(0.5 - abs(posAlong - 0.5), 0.0, 0.5) * 1.15;
vec3 neigh = (dirY > 0.0) ? cU : cD;
blended = mix(blended, neigh, cov);
}
if (edgeV > 0.5) {
float spanD = 0.0;
float spanU = 0.0;
float rightSide = step(abs(lC - luma(cL)), abs(lC - luma(cR)));
float dirX = (rightSide > 0.5) ? 1.0 : -1.0;
for (int s = 1; s <= 6; s++) {
float fs = float(s);
float l1 = luma(fetchPx(pix + vec2(0.0, -fs), cell, iTime));
float l2 = luma(fetchPx(pix + vec2(dirX, -fs), cell, iTime));
if (abs(l1 - l2) < thresh) break;
spanD = fs;
}
for (int s = 1; s <= 6; s++) {
float fs = float(s);
float l1 = luma(fetchPx(pix + vec2(0.0, fs), cell, iTime));
float l2 = luma(fetchPx(pix + vec2(dirX, fs), cell, iTime));
if (abs(l1 - l2) < thresh) break;
spanU = fs;
}
float totalSpan = max(spanD + spanU + 1.0, 1.0);
float posAlong = (spanD + 0.5) / totalSpan;
float cov = clamp(0.5 - abs(posAlong - 0.5), 0.0, 0.5) * 1.15;
vec3 neigh = (dirX > 0.0) ? cR : cL;
blended = mix(blended, neigh, cov * 0.85);
}
// Smooth sub-cell anti-aliased readout at display resolution
vec2 uvExact = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 fineRef = evalAliased(uvExact, iTime);
col = mix(blended, fineRef, 0.35);
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.98, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| smaa-live | Tesla T4 1920x1080 | 6.61× baseline (moderate) · 0.217 ms / 0.219 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| smaa-live | NVIDIA L4 1920x1080 | 5.66× baseline (light) · 0.090 ms / 0.090 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| smaa-live | NVIDIA A100-SXM4-40GB 1920x1080 | 4.44× baseline (light) · 0.128 ms / 0.132 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Temporal Anti-Aliasing: SMAA handles geometric edges while TAA handles shading; the T2x mode shares jitter.
Sources
- primaryJorge Jimenez, Jose I. Echevarria, Tiago Sousa, Diego Gutierrez (2012). SMAA: Enhanced Subpixel Morphological Antialiasing. Computer Graphics Forum.Verified via crossref · 2026-11-29doi:10.1111/j.1467-8659.2012.03014.x
- implementationiryoku (2011). iryoku/smaa. SMAA is a very efficient GPU-based MLAA implementation (DX9, DX10, DX11 and OpenGL), capable of handling subpixel features seamlessly, and featuring an improved and advanced pattern detection & handling mechanism.GitHub API · license NOASSERTION · 2026-11-29
- implementationpmndrs (2015). pmndrs/postprocessing. A post processing library for three.js.GitHub API · license Zlib · 2026-11-29