DKNazar Game Development

My notes on game dev and graphics programming

Temporal Anti-aliasing


Preamble


One of my first tasks as a graphics programmer was to improve their TAA implementation. The main issue was constant flickering on stationary camera shots. I started with zero knowledge and no one at the company had much information, the shader was almost a decade old. The first thing I did was read through the shader to try and understand where the flickering was occuring and see if I could just tweak a value to reduce it. Probably not the best first step, I quickly realised I had a lot of research to do, and that most of this job is actually research!


Quickly Explain


TAA is essentially jiggling the camera every frame, then blurring/blending them together to produce a smooth looking image. Aliased pixels are where geometry (and other) detail is unable to be represented on the low resolution screen. It lands between pixels (subpixel) and cannot be perfectly represented, causing jagged edges. By jiggling (or jittering) the camera a tiny subpixel amount these jagged edges will snap back and forth between different pixel locations. By blending these subpixel movements every frame the image will blur these edges over time, resulting in a smooth image.

The main strength of TAA over other screen space anti-aliasing techniques is that it is temporally stable, during camera motion the image should still be smooth and free of aliasing. Unlike FXAA or SMAA (although there are SMAA+TAA techniques).

Cheat Sheet


Just want the answers? Every link I think is useful and a quick glossary. In retrospect it is easy to find this info, but at the time without a working lexicon it is difficult.

Glossary

Research Links

TAA Overview


Core Steps

So I recommend reading/watching the links above in that order but the key steps are:


That is what I consider the core of TAA, the rest is somewhat more application specific.

Increasing Quality


When you have tiny geometry on screen like a wire fence if you jitter the camera that geometry no longer exists in the next frame, but when we jitter it for the frame after that it will exist again and pop back in causing flickering. A method briefly mentioned in UE4’s talk is by recording these impulses in another buffer (or alpha channel) and effectively decreasing that pixel’s importance. I achieved this by increasing the acceptable colour bounds in varience clipping, it would allow more ghosting in these flickering spots causing them to blend nicely.

Specular flickering where each frame the specular material causes very bright highlights to jitter across the edges of geometry, similar to the tiny geometry flickering. These can have very high HDR values which is difficult to handle, doing a tonemapping/luminance filtering step to both history and current colour (as seen in Alex Tardif’s TAA) can greatly mitigate this, this was the main solution to our own TAA flickering.



End Notes


In the end the TAA I had to fix up had many issues, and unpacking them was almost impossible. In the end I did almost a full rewrite and backtracked from there to figure out what went wrong in our previous TAA. Turns out in an effort to reduce ghosting we increased the blend factor of 10% to much larger amounts when velocity increased (camera or object motion). This maybe sounds good at first glance since taking more of the current frame will reduce ghosting and result in sharper images. But we lose the main strength of TAA that it is temporally stable, most other screen-space anti-aliasing break during camera motion, not TAA. This was effecively throwing out most of our work as soon as the camera moved. There were a number of other small issues like tonemapping incorrectly and oddities with jitter calculations, but that was the most egregious.