---
id: "smaa"
title: "SMAA"
aliases: [Subpixel Morphological Anti-Aliasing]
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity]
year_introduced: 2012
inputs: [ldr-image]
outputs: [ldr-image]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Jimenez et al., 2012"
url: "https://texelatlas.vercel.app/t/smaa/"
sources_verified_at: "2026-11-29"
---
# SMAA (Jimenez et al., 2012)

> 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.

## 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

## 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 use it

Choose it when you want clean geometric edges at modest cost and no motion vectors.

Prefer [FXAA](https://texelatlas.vercel.app/t/fxaa.md) when you must stay in a single pass. Prefer [Temporal Anti-Aliasing](https://texelatlas.vercel.app/t/temporal-anti-aliasing.md) when shading and subpixel aliasing matter more than edge shape. SMAA T2x gives a taste of temporal supersampling if you have jitter and velocity.

## Cost

cheap — Three passes plus two small lookup textures; still around a millisecond or less at 1080p (qualitative).
Measured GPU Weight: 6.61× baseline (moderate) — 0.2174 ms median / 0.2189 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 5.66× baseline (light) — 0.09 ms median (2.42× faster on L4).
Ampere A100 scaling: 4.44× baseline (light) — 0.1279 ms median (1.7× faster on A100).

## Failure modes

- 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

## Engine support

- blender: builtin — `Preferences > Viewport > Quality > Viewport Anti-Aliasing (morphological screen-space AA)` (evidence: https://docs.blender.org/manual/en/5.2/editors/preferences/viewport.html, checked 2026-12-01)
- godot: builtin — `Viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_SMAA` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Viewport.xml, checked 2026-12-01)
- threejs: official — `import { smaa } from 'three/addons/tsl/display/SMAANode.js' (WebGL: SMAAPass)` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/tsl/display/SMAANode.js, checked 2026-12-01)
- unity: builtin — `Camera > Rendering > Anti-aliasing = Subpixel Morphological Anti-aliasing (SMAA)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/SubpixelMorphologicalAntialiasing.shader, checked 2026-12-01) — URP and HDRP.

## Dataflow

- Inputs: ldr-image
- Outputs: ldr-image
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity

## Presets

### SMAA — aliased 1x raster edges (left) vs morphological L/Z/U edge search & subpixel coverage blending (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_PIXEL_SIZE": 3.5,
  "P_EDGE_THRESH": 0.12,
  "P_EDGE_DEBUG": 0.25,
  "P_SPLIT": 0.48
}
```

```glsl
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.

## Lineage

- extends [FXAA](https://texelatlas.vercel.app/t/fxaa.md)

## Combines with

- [Temporal Anti-Aliasing](https://texelatlas.vercel.app/t/temporal-anti-aliasing.md): SMAA handles geometric edges while TAA handles shading; the T2x mode shares jitter.

## Sources

1. [primary] Jorge Jimenez, Jose I. Echevarria, Tiago Sousa, Diego Gutierrez (2012) SMAA: Enhanced Subpixel Morphological Antialiasing. Computer Graphics Forum. https://doi.org/10.1111/j.1467-8659.2012.03014.x (verified via crossref on 2026-11-29)
2. [implementation] iryoku (2011) iryoku/smaa. https://github.com/iryoku/smaa License: NOASSERTION. (verified via github on 2026-11-29)
3. [implementation] pmndrs (2015) pmndrs/postprocessing. https://github.com/pmndrs/postprocessing License: Zlib. (verified via github on 2026-11-29)

## Cite this entry

Texel. "SMAA." https://texelatlas.vercel.app/t/smaa/ (accessed 2026-12-01).
