Anti-Aliasing
Aliasing occurs when continuous signals are sampled at discrete intervals, causing jagged edges (jaggies), moirรฉ patterns, and temporal flickering. Anti-aliasing techniques reduce these artifacts.
Supersampling (SSAA)
Renders the scene at a higher resolution then downsamples. The simplest but most expensive anti-aliasing method.
Supersampling 4x:
Render at 4x resolution:
For each pixel, compute 4 sub-pixels
+---+---+
| 0 | 1 | 4 samples per pixel
+---+---+
| 2 | 3 |
+---+---+
pixel_color = (c0 + c1 + c2 + c3) / 4
4x SSAA: 4x rendering cost
16x SSAA: 16x rendering cost
Multisampling (MSAA)
Like supersampling but shares computation within each triangle. Only samples that fall inside the triangle contribute. More efficient than full SSAA.
MSAA with 4 samples:
Sample positions within pixel:
+-------+-------+
| s0 | s1 |
+-------+-------+
| s2 | s3 |
+-------+-------+
For each triangle covering the pixel:
Count how many samples fall inside
Shade only once per triangle
Blend based on coverage
Coverage = samples_inside / total_samples
pixel = coverage * triangle_color + (1-coverage) * background
Post-Process Anti-Aliasing
Techniques like FXAA and SMAA work on the final rendered image. They are fast but may blur textures or miss thin features.
FXAA (Fast Approximate AA):
1. Detect edge pixels based on luminance
2. Determine edge direction
3. Blend pixel with neighbors along edge
Very fast, works on any hardware
May blur fine details
SMAA (Subpixel Morphological AA):
1. Edge detection
2. Pattern recognition
3. Blending
Better quality than FXAA, moderate cost
Temporal Anti-Aliasing (TAA)
Uses information from previous frames to increase effective sample count. Each frame uses a different sample offset, and results are accumulated over time.
TAA Process:
1. Jitter sample position each frame
(using Halton sequence or similar)
2. Render with single sample at jittered position
3. Combine current frame with accumulated history
4. Apply motion blur correction
Over N frames: effectively N samples per pixel
Cost: ~1x + history buffer + blending
Pros: High quality, low per-frame cost
Cons: Ghosting artifacts on fast motion