Skip to content

Temporal Anti-Aliasing #3663

Closed
Closed

Description

@superdump

Description

Aliasing happens in an image (i.e. spatial aliasing) when a low resolution sampling is made from a higher-resolution representation.

The more well-known aliasing along the edges of triangles as they are sampled as part of the rasterisation process is addressed by MSAA (Multi-Sample Anti-Aliasing).

As the detail of textures increased, there has been a similar problem with, let's say the contents of the surface of the triangles as a high resolution texture on a model that is far away is being sampled at a much lower resolution in order to shade an individual screen fragment. This can be addressed by mip mapping with involves sampling from appropriately-filtered, downscaled versions of the full resolution original texture such that when the model is far away, samples are taken from a lower resolution texture. Filtering can be done affecting the way that the textures are sampled such as trilinear and anisotropic filtering.

As part of physically-based lighting models, specular highlights as light reflects off a shiny surface when viewed from a specific angle also cause aliasing as the bright spot fills an entire screen fragment where it would perhaps have been a tiny speck in the analogue world. The way that modern renderers solve this may vary but Temporal Anti-Aliasing has emerged as the leading solution in the game industry. It involves practically accumulating samples over multiple frames (as the 'temporal' in its name suggests), making sure to match up the samples for the current frame with their position in the previous frame, and, in my opinion very interestingly, jittering (moving around) the camera position. The camera jitter makes it so that when the camera is 'still' it is technically not and so the technique can still address the aliasing problems it aims to remove. It also has additional positive side effects as instead of sampling the scene only at the positions directly in-line with the screen fragments, the technique is sampling at many positions close to and around those positions. This means that the technique gathers more information than 'basic' non-jittered rendering and so Temporal Anti-Aliasing techniques can also be used as a sort of spatio-temporal super-sampling which allows for upscaling as part of the process. TAA's temporal filtering enables a number of sparse sampling techniques that look noisy without filtering but the mathematics of blue noise and low discrepancy sequences applied to the patterns of sampling produce excellent results for fewer samples. This can be applied to ambient occlusion and shadow techniques among others.

Another solution could be this: https://www.jcgt.org/published/0010/02/02/paper.pdf This uses the derivative of the normal to detect where aliasing might happen and boosts the surface roughness to reduce potential aliasing.

Some downsides and complications of TAA are that 'averaging' pixels over time causes smearing / blurring / ghosting artifacts, the need for motion vectors to reproject fragments from the current frame into the history buffer has a few problems of occlusion/disocclusion (a point on a surface becoming blocked or visible between frames), and obtaining motion vectors for animated vertices that are not simply defined by the vertex buffer and model transform. These are solvable, if complicated.

Solution

Activity

  1. added
    A-RenderingDrawing game state to the screen
    C-FeatureA new feature, making something new possible
    on Jan 13, 2022
  2. superdump commented on Jan 13, 2022

    @superdump
    ContributorAuthor

    Some additional information from @aclysma - normal maps can be filtered. It was mentioned in a talk (using "LEAN/CLEAN/Toksvig"):

    Unrelatedly, Brian Karis on TAA (a twitter thread): https://twitter.com/BrianKaris/status/1327712610364522496?s=20

  3. superdump commented on Mar 25, 2022

    @superdump
    ContributorAuthor

    FSR 2.0 is a combined TAA and upscaling solution with additional features such as auto-exposure and sharpening. It could be worth considering porting it to be usable with bevy/wgpu. Apparently AMD worked with Unreal Engine on their TSR combined TAA + upscaling and that has worked very well without requiring any special hardware. FSR 2.0 is likely using a lot of knowledge gained from that.

  4. zamazan4ik commented on Jun 15, 2022

    @zamazan4ik

    Maybe this will be useful too - godotengine/godot#61319 (initial TAA implementation in Godot 4)

  5. JMS55 commented on Nov 3, 2022

    @JMS55
    Contributor
  6. Calinou commented on Dec 2, 2022

    @Calinou

    Regarding whether to go with a custom implementation or FSR 2, I think going for FSR 2 exclusively makes the most sense. Godot went with Spartan Engine's TAA implementation, but that engine replaced its own TAA implementation with FSR 2 shortly after TAA was merged in Godot.

    FSR 2's algorithm is more expensive at a given resolution compared to traditional TAA, but if you reduce the resolution scale to roughly 90%, you get the same performance as less advanced TAA algorithms, but with better quality across the board (even in motion). And for GPUs where you have the headroom, using FSR 2 at native resolution provides the best quality seen in any open source TAA algorithm.

    Regardless, having a TAA solution is still better than not having a TAA solution 🙂

  7. moved this from In Progress to In Review in Rendering (Old)on Feb 7, 2023
  8. bakcxoj commented on Feb 22, 2023

    @bakcxoj
    Contributor

    I see the corresponding PR is in the 0.10 milestone. Should this ticket join it?

  9. moved this from In Review to Done in Rendering (Old)on Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions