skip to content

Anti-Aliasing and Post-Processing

Where aliasing comes from and how MSAA, FXAA, SMAA and TAA fight it, plus tone mapping, bloom and SSAO. Interviewers ask why TAA ghosts to test whether you reason about sampling over time.

on this pageshow

explore

questions

6

How does MSAA differ from supersampling in what it samples, shades and stores, and which aliasing does it leave untouched?

level: middleimportance: must knowfreq 60%

answer

  1. coverage versus shading frequency
  2. one shade per pixel per triangle
  3. samples stored, then resolved
  4. edges only, not shader detail

basics

~20 s

Supersampling shades every sample, multiplying shading cost. MSAA tests coverage and depth at several samples per pixel but shades once per pixel per triangle, then averages them: geometric edges smooth, while shader and alpha-test aliasing remain.

solid answer

~40 s

Aliasing comes from taking one point sample per pixel of a scene with detail finer than a pixel, so edges stair-step and thin features crawl as they move. **Supersampling (SSAA)** renders N samples per pixel, shades every one and filters down: it fixes every kind of aliasing but costs about N times the shading, bandwidth and memory. **MSAA** keeps N coverage and depth samples per pixel but runs the fragment program **once per pixel per covering triangle** and writes that colour to every covered sample; a **resolve** then averages each pixel's samples. Interior pixels cost what they cost without MSAA, edge pixels are shaded once per triangle touching them, and colour and depth storage still grow N times. Because colour is computed once, MSAA leaves **shader aliasing** (sparkling specular) and **alpha-tested edges** untouched.

go deeper

for a junior

Know that aliasing is stair-stepped, crawling edges from one sample per pixel, and that SSAA, MSAA, FXAA and SMAA are the classic remedies with very different costs.

for a middle

Explain that MSAA tests coverage and depth per sample but shades once per pixel per triangle, then resolves, and list what that leaves aliased: specular sparkle and alpha-tested edges.

for a senior

Show production judgment: the HDR resolve trap and tone-mapped resolves, MSAA's cost on dense small geometry, and enabling per-sample shading only on foliage or trim.

for a principal

Weigh MSAA's clean, stable edges against its memory, its poor fit with renderers that keep many per-pixel targets, and modern temporal pipelines when choosing the project's approach.

## Where aliasing comes from A rasterizer decides what a pixel shows by testing **one sample point** per pixel, usually its centre. The scene contains detail finer than a pixel: a triangle edge is a step from one colour to another, and a specular highlight on a bumpy surface can be a fraction of a pixel wide. Sampling a signal below the rate its finest detail needs produces **aliasing**: high frequencies fold back as false low-frequency patterns. In a still image this shows as **stair-stepped edges**; in motion it shows as **crawling** edges and **flickering** thin objects, which players usually notice more. There are two broad remedies: take more samples per pixel, or reconstruct edges from the finished image. ## Supersampling: brute force **Supersampling anti-aliasing (SSAA)** renders the frame with N samples per pixel, for example at twice the width and height for N = 4, and filters the result down to the output size. Every sample is rasterized, depth-tested and **shaded**, so it removes every kind of aliasing at once: edges, specular sparkle, texture shimmer and alpha-tested cutouts. The cost is what makes it rare in real time: about N times the fragment work, N times the bandwidth and N times the colour and depth memory. It survives as an option for spare GPU headroom and as the reference other methods are judged against. ## MSAA: coverage at N samples, shading at one **Multisample anti-aliasing (MSAA)** separates two jobs SSAA does together: deciding **coverage** and computing **colour**. With 4x MSAA: 1. The rasterizer tests each triangle against **four sample positions** inside every pixel, usually in a rotated pattern so near-horizontal and near-vertical edges get four distinct steps. 2. Depth and stencil are tested and stored **per sample**, so surfaces that intersect are resolved at sub-pixel precision. 3. The fragment program runs **once per pixel per triangle** that covers at least one of its samples, and its colour is written to **every covered sample** of that triangle. 4. After the pass, a **resolve** filters each pixel's samples, by default averaging them, into one colour. A pixel entirely inside one triangle is shaded once, exactly as without MSAA. A pixel on the edge between two triangles is shaded twice, once for each. Shading cost therefore grows with the number of edge pixels rather than with N, and a scene of very small triangles loses most of the saving. Memory does not shrink: colour and depth are stored per sample, so a 4x target holds four times the data before any lossless compression the GPU applies. ## The resolve and its HDR trap The default resolve is a **box filter**, the plain average of the samples. If the samples hold **linear HDR** values, one very bright sample dominates. Picture three samples of a dark railing at 0.1 and one of sunlit sky at 40: the average is about 10, and after tone mapping that pixel is nearly as white as the sky, so the soft edge MSAA paid for disappears and the edge looks aliased again. Renderers fix this by tone mapping each sample, or weighting it by `1 / (1 + luminance)`, before averaging and inverting the curve afterwards, or by resolving after tone mapping. ## What MSAA does not fix Because colour is computed once per pixel per triangle, MSAA anti-aliases only **geometric edges and depth intersections**. It leaves: - **Shader aliasing**: tight specular highlights on normal-mapped surfaces and high-frequency procedural patterns still sparkle. - **Alpha-tested edges**: discarding fragments by a texture's alpha happens inside the single shading run, so a cutout edge is all or nothing; turning alpha into a coverage mask is a cutout technique covered with transparency. - **Texture shimmer** that mipmapping does not catch. MSAA also grows expensive in renderers that store many per-pixel targets, since every such target must become multisampled; how each shading architecture copes is a separate topic. Running the fragment program **per sample** for selected materials turns MSAA into supersampling on those surfaces only, at up to N times their shading cost. ## Post-process edge anti-aliasing: FXAA and SMAA The cheap alternative works on the finished image. **FXAA** detects edges from **luminance contrast** between neighbouring pixels, estimates each edge's direction and extent, and blends across it in one full-screen pass. **SMAA** splits the job into edge detection, a **blending-weight** pass that matches edge shapes against precomputed patterns, and a neighbourhood blend, which keeps more texture detail. Both are fast and work with any shading architecture, but they can only redistribute what was sampled: a power line thinner than a pixel that rasterized as broken dots stays broken, and nothing stops it crawling from frame to frame. Temporal anti-aliasing exists to gather the missing samples over time. | Method | Coverage samples | Shading runs per pixel | Extra memory | Reduces shader aliasing | Stable in motion | |---|---|---|---|---|---| | SSAA | N | N | N times colour and depth | yes | good | | MSAA | N | 1 per covering triangle | N times colour and depth | no | edges only | | FXAA | 1 | 1 | almost none | slightly, by blurring | poor | | SMAA | 1 | 1 | edge and weight targets | slightly | poor |

  • What does per-sample shading change when it is enabled on top of MSAA?
    The fragment program runs once per covered sample instead of once per pixel, so MSAA becomes supersampling for the triangles drawn that way. That removes shader and alpha-test aliasing on those surfaces at up to N times their shading cost, which is why renderers enable it selectively, for example on foliage or thin wire fences, rather than for the whole frame.
  • Why does MSAA save little over supersampling on a scene of very small triangles?
    MSAA shades once per pixel per covering triangle. When triangles are about a pixel in size, most pixels are edge pixels touched by several triangles, so the fragment program runs several times per pixel anyway, while the per-sample colour and depth memory and bandwidth stay the same. The saving MSAA gets from shading interiors once mostly disappears.
  • Why do FXAA and SMAA fail to stop a thin power line from crawling?
    They work on the finished single-sample image. A line thinner than a pixel rasterizes as a broken row of dots whose positions change as it moves; edge detection can soften the dots it finds but cannot invent the coverage that was never sampled, so the line still flickers frame to frame. More samples, spatial or temporal, are the only fix.

  • MSAA runs the fragment program once per sample, so it costs as much as supersampling.
  • MSAA removes specular sparkle and texture shimmer inside triangles.
  • MSAA saves memory because it stores only one colour per pixel.
  • FXAA can rebuild a sub-pixel power line that rasterized as broken dots.
  • Averaging linear HDR samples always gives the smoothest MSAA edges.
  • Alpha-tested foliage edges are smoothed by MSAA with no extra work.
open as a page

How does temporal anti-aliasing accumulate samples across frames, and why do thin railings leave ghost trails during a fast camera pan?

level: middleimportance: must knowfreq 62%

basics

~20 s

TAA jitters the projection by a sub-pixel offset each frame, reprojects the accumulated history with motion vectors and blends in a little of the new frame. Ghosts appear when history no longer matches the surface: disocclusion, wrong motion vectors, weak rejection.

open as a page

Why does a renderer light the scene in linear HDR and tone map it, instead of clamping each pixel to the display range?

level: juniorimportance: should knowfreq 55%

basics

~20 s

Real light spans far more range than a display, so lighting is computed in linear floating point, then exposed and tone mapped by a curve that compresses highlights smoothly. Clamping instead turns bright skies flat white and shifts their hue.

open as a page

How does screen-space ambient occlusion estimate occlusion from the depth buffer, and why does it need per-pixel noise and a blur?

level: middleimportance: should knowfreq 48%

basics

~20 s

SSAO places a few points in a hemisphere around each pixel's surface, projects them and counts how many lie behind the depth buffer. Few samples band, so tiled noise rotates the kernel per pixel and a depth-aware blur removes the noise.

open as a page

After a renderer swaps its own TAA for a temporal upscaler at a lower internal resolution, textures blur and particles smear; which inputs did it get wrong?

level: seniorimportance: should knowfreq 38%

basics

~20 s

A temporal upscaler is TAA that reconstructs a larger output, so it needs correct jitter, depth, motion vectors and exposure. Blurry textures mean no negative mip bias for the lower internal resolution; smearing particles mean missing motion vectors or reactive mask.

open as a page

As rendering lead for a game shipping on several hardware tiers, how do you set the anti-aliasing and upscaling policy, including each tier's internal resolution?

level: principalimportance: should knowfreq 28%

basics

~20 s

Build one temporal pipeline every tier shares, set each tier's output and internal resolution from its GPU time budget, put rival upscalers behind one interface, keep a non-temporal fallback, and make motion vectors and masks a content rule.

open as a page