{
 "id": "smaa",
 "title": "SMAA",
 "aliases": [
  "Subpixel Morphological Anti-Aliasing"
 ],
 "domain": "post",
 "subdomain": "anti-aliasing",
 "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",
 "summary": "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.",
 "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": "Choose it when you want clean geometric edges at modest cost and no motion vectors.\n\nPrefer `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.",
 "cost": {
  "class": "cheap",
  "notes": "Three passes plus two small lookup textures; still around a millisecond or less at 1080p (qualitative)."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1111/j.1467-8659.2012.03014.x",
   "type": "paper",
   "title": "SMAA: Enhanced Subpixel Morphological Antialiasing",
   "authors": [
    "Jorge Jimenez",
    "Jose I. Echevarria",
    "Tiago Sousa",
    "Diego Gutierrez"
   ],
   "year": 2012,
   "venue": "Computer Graphics Forum",
   "url": "https://doi.org/10.1111/j.1467-8659.2012.03014.x",
   "ids": {
    "doi": "10.1111/j.1467-8659.2012.03014.x"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2012.03014.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2012.03014.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2012.03014.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2012.03014.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2012.03014.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "jimenez2012smaa"
  },
  {
   "role": "implementation",
   "key": "gh:iryoku/smaa",
   "type": "code",
   "title": "iryoku/smaa",
   "description": "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.",
   "authors": [
    "iryoku"
   ],
   "year": 2011,
   "venue": "GitHub",
   "url": "https://github.com/iryoku/smaa",
   "ids": {
    "repo": "iryoku/smaa"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 1148,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2024-07-10T16:38:26Z",
    "language": "C++",
    "homepage": "http://www.iryoku.com/smaa/",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/iryoku/smaa",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "iryoku2011iryoku"
  },
  {
   "role": "implementation",
   "key": "gh:pmndrs/postprocessing",
   "type": "code",
   "title": "pmndrs/postprocessing",
   "description": "A post processing library for three.js.",
   "authors": [
    "pmndrs"
   ],
   "year": 2015,
   "venue": "GitHub",
   "url": "https://github.com/pmndrs/postprocessing",
   "ids": {
    "repo": "pmndrs/postprocessing"
   },
   "license": "Zlib",
   "extra": {
    "stars": 3009,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-22T15:27:35Z",
    "language": "JavaScript",
    "homepage": null,
    "license_name": "zlib License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/pmndrs/postprocessing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "pmndrs2015pmndrs"
  }
 ],
 "presets": [
  {
   "id": "smaa-live",
   "title": "SMAA — aliased 1x raster edges (left) vs morphological L/Z/U edge search & subpixel coverage blending (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_PIXEL_SIZE": 3.5,
    "P_EDGE_THRESH": 0.12,
    "P_EDGE_DEBUG": 0.25,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_PIXEL_SIZE = 3.50; // P Raster Pixel Zoom [1.5, 7.0, 0.25]\nconst float P_EDGE_THRESH = 0.12; // P Edge Threshold [0.04, 0.35, 0.02]\nconst float P_EDGE_DEBUG = 0.25; // P Edge Overlay [0.0, 1.0, 0.05]\nconst float P_SPLIT = 0.48; // P Aliased / SMAA [0.0, 1.0, 0.02]\n\nvec2 rot2(vec2 p, float a) {\n  float c = cos(a);\n  float s = sin(a);\n  return vec2(c * p.x - s * p.y, s * p.x + c * p.y);\n}\n\n// Sharp high-contrast geometric blades & polygons that produce classic 1x stair-step jaggies\nvec3 evalAliased(vec2 uv, float t) {\n  vec3 col = mix(vec3(0.07, 0.10, 0.16), vec3(0.16, 0.24, 0.36), smoothstep(-0.5, 0.5, uv.y));\n  vec2 p = rot2(uv, 0.18 * sin(t * 0.45) + 0.12);\n\n  // Sharp tilted white & orange architectural monoliths\n  vec2 b1 = abs(p - vec2(-0.18, 0.02)) - vec2(0.24, 0.34);\n  if (max(b1.x, b1.y) < 0.0) {\n    col = mix(vec3(0.86, 0.89, 0.94), vec3(0.68, 0.74, 0.84), smoothstep(-0.3, 0.3, p.y));\n  }\n  vec2 p2 = rot2(uv - vec2(0.14, -0.04), -0.34 + 0.10 * cos(t * 0.5));\n  vec2 b2 = abs(p2) - vec2(0.26, 0.18);\n  if (max(b2.x, b2.y) < 0.0) {\n    col = vec3(0.95, 0.44, 0.16);\n  }\n  // Crisp diagonal cyan blade cutting across both shapes\n  vec2 p3 = rot2(uv, 0.28);\n  if (abs(p3.y - 0.05) < 0.048 && abs(p3.x) < 0.55) {\n    col = vec3(0.14, 0.86, 0.96);\n  }\n  // Fine circular ring with high-contrast boundary\n  float rc = length(uv - vec2(0.02, 0.02));\n  if (abs(rc - 0.28) < 0.024) {\n    col = vec3(0.10, 0.12, 0.18);\n  }\n  return col;\n}\n\nvec3 fetchPx(vec2 cellCoord, float cell, float t) {\n  vec2 fc = (cellCoord + 0.5) * cell;\n  vec2 uv = (fc - 0.5 * iResolution.xy) / iResolution.y;\n  return evalAliased(uv, t);\n}\n\nfloat luma(vec3 c) {\n  return dot(c, vec3(0.299, 0.587, 0.114));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float cell = clamp(P_PIXEL_SIZE, 1.2, 8.0);\n  float thresh = clamp(P_EDGE_THRESH, 0.03, 0.4);\n  float dbg = clamp(P_EDGE_DEBUG, 0.0, 1.0);\n\n  vec2 pix = floor(fragCoord / cell);\n  vec3 cC = fetchPx(pix, cell, iTime);\n  vec3 cL = fetchPx(pix + vec2(-1.0, 0.0), cell, iTime);\n  vec3 cR = fetchPx(pix + vec2(1.0, 0.0), cell, iTime);\n  vec3 cD = fetchPx(pix + vec2(0.0, -1.0), cell, iTime);\n  vec3 cU = fetchPx(pix + vec2(0.0, 1.0), cell, iTime);\n\n  // Pass 1: Local-contrast-adapted luma edge detection\n  float lC = luma(cC);\n  float dH = max(abs(lC - luma(cD)), abs(lC - luma(cU)));\n  float dV = max(abs(lC - luma(cL)), abs(lC - luma(cR)));\n  float edgeH = step(thresh, dH);\n  float edgeV = step(thresh, dV);\n\n  vec3 col = cC;\n  if (screenX < split) {\n    // Left: Raw 1x aliased pixels + optional SMAA Pass-1 edge detection highlight (red=horiz, green=vert)\n    vec3 edgeTint = vec3(edgeH, edgeV, 0.0);\n    col = mix(cC, edgeTint * 1.25, dbg * clamp(edgeH + edgeV, 0.0, 1.0) * 0.65);\n  } else {\n    // Right: Pass 2 & 3 -- Search along horizontal/vertical span to measure stair-step run length & blend coverage!\n    vec3 blended = cC;\n    if (edgeH > 0.5) {\n      float spanL = 0.0;\n      float spanR = 0.0;\n      float upSide = step(abs(lC - luma(cD)), abs(lC - luma(cU)));\n      float dirY = (upSide > 0.5) ? 1.0 : -1.0;\n      for (int s = 1; s <= 6; s++) {\n        float fs = float(s);\n        float l1 = luma(fetchPx(pix + vec2(-fs, 0.0), cell, iTime));\n        float l2 = luma(fetchPx(pix + vec2(-fs, dirY), cell, iTime));\n        if (abs(l1 - l2) < thresh) break;\n        spanL = fs;\n      }\n      for (int s = 1; s <= 6; s++) {\n        float fs = float(s);\n        float l1 = luma(fetchPx(pix + vec2(fs, 0.0), cell, iTime));\n        float l2 = luma(fetchPx(pix + vec2(fs, dirY), cell, iTime));\n        if (abs(l1 - l2) < thresh) break;\n        spanR = fs;\n      }\n      float totalSpan = max(spanL + spanR + 1.0, 1.0);\n      float posAlong = (spanL + 0.5) / totalSpan;\n      // Trapezoidal area coverage lookup approximation for L/Z crossing patterns\n      float cov = clamp(0.5 - abs(posAlong - 0.5), 0.0, 0.5) * 1.15;\n      vec3 neigh = (dirY > 0.0) ? cU : cD;\n      blended = mix(blended, neigh, cov);\n    }\n    if (edgeV > 0.5) {\n      float spanD = 0.0;\n      float spanU = 0.0;\n      float rightSide = step(abs(lC - luma(cL)), abs(lC - luma(cR)));\n      float dirX = (rightSide > 0.5) ? 1.0 : -1.0;\n      for (int s = 1; s <= 6; s++) {\n        float fs = float(s);\n        float l1 = luma(fetchPx(pix + vec2(0.0, -fs), cell, iTime));\n        float l2 = luma(fetchPx(pix + vec2(dirX, -fs), cell, iTime));\n        if (abs(l1 - l2) < thresh) break;\n        spanD = fs;\n      }\n      for (int s = 1; s <= 6; s++) {\n        float fs = float(s);\n        float l1 = luma(fetchPx(pix + vec2(0.0, fs), cell, iTime));\n        float l2 = luma(fetchPx(pix + vec2(dirX, fs), cell, iTime));\n        if (abs(l1 - l2) < thresh) break;\n        spanU = fs;\n      }\n      float totalSpan = max(spanD + spanU + 1.0, 1.0);\n      float posAlong = (spanD + 0.5) / totalSpan;\n      float cov = clamp(0.5 - abs(posAlong - 0.5), 0.0, 0.5) * 1.15;\n      vec3 neigh = (dirX > 0.0) ? cR : cL;\n      blended = mix(blended, neigh, cov * 0.85);\n    }\n    // Smooth sub-cell anti-aliased readout at display resolution\n    vec2 uvExact = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n    vec3 fineRef = evalAliased(uvExact, iTime);\n    col = mix(blended, fineRef, 0.35);\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.98, 1.0), sep);\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "smaa",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:25.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6318,
      "std": 0.1858,
      "min": 0.3798,
      "max": 0.9014
     },
     "image": "/specimens/smaa-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "fxaa",
  "temporal-anti-aliasing"
 ],
 "extends": [
  "fxaa"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "temporal-anti-aliasing",
   "why": "SMAA handles geometric edges while TAA handles shading; the T2x mode shares jitter."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/post/smaa.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Jimenez et al., 2012",
 "url": "https://texelatlas.vercel.app/t/smaa/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 6.61,
  "tier": "moderate",
  "p50_ms": 0.2174,
  "p95_ms": 0.2189,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "smaa-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 5.66,
   "tier": "light",
   "p50_ms": 0.09,
   "p95_ms": 0.0905,
   "speedup_x": 2.42,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 4.44,
   "tier": "light",
   "p50_ms": 0.1279,
   "p95_ms": 0.1315,
   "speedup_x": 1.7,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}