TAA - History
Task
Implement a basic Temporal Anti-Aliasing (TAA) pass by blending the current frame’s color with the previous frame’s color using a fixed blend factor of 0.9. This technique reduces aliasing by accumulating color information over time.
iPrevFrameColor is a texture containing the previous frame’s color.
Theory
Imagine drawing a smooth diagonal line using square tiles. You’ll end up with a staircase pattern instead of a clean slope. That’s aliasing.
In graphics aliasing happens when we try to show smooth shapes or edges using a grid of pixels. The result is jagged edges, flickering, or shimmering especially on thin lines or detailed textures.
Anti-Aliasing
Anti-aliasing is the technique used to smooth out those jagged edges.
Instead of showing a sharp transition between pixels, we blend colors around edges to make them look smoother.
Temporal Anti-Aliasing
TAA is a smarter kind of anti-aliasing. Instead of just looking at one frame, it looks at multiple frames over time Most pixels don’t change much between frames. So we can average the color of a pixel with its value from the previous frame using history buffer to reduce flickering and noise.
History Buffer
The history buffer is a texture with the same resolution and format as your render target that stores the blended result of the previous frame. It’s used as an input in the next frame to smooth out aliasing over time.
Lifecycle Overview
- render the current frame;
- for each pixel, you look up its color from the history buffer;
- blend the current color with the history color;
- output the result to screen;
- copy the current frame into the history buffer for the next frame.
Pseudocode
vec3 currentColor = texture(currentFrame, uv).rgb;
vec3 historyColor = texture(historyBuffer, uv).rgb;
float blendFactor = 0.9; // Higher = smoother
vec3 finalColor = mix(currentColor, historyColor, blendFactor);
// Output the result to screen
// Copy the current frame into the history buffer
TAA Compatibility
- software-based, implemented in shaders;
- can be applied in deferred rendering;
- works in screen-space.