Search Unity

HDRP TAA

Discussion in 'High Definition Render Pipeline' started by jjejj87, Dec 31, 2019.

  1. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    Last edited: Dec 31, 2019
    konsic likes this.
  2. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I've implemented most of the hacks from that article for tad older HDRP as proof of concept. There are few things to note with this approach:

    - Hacks in that article are very specific to chase camera and car application, it doesn't work that well for generic use cases
    - You need to modify HDRP source code directly to get access to stencil buffer
    - Using velocity in mask like in that article results in notable jittering due to frametime differences in Unity rendering (motion vectors data just jumps too much between the frames):

     
    jjejj87 likes this.
  3. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    As additional notes:

    - the whole idea on that amazon article is that you bypass TAA for areas that would ghost, in that article they just blurred the area where TAA was omitted. In my test, I replaced this area with FXAA but since Unity's TAA changes the brightness of the image a bit, I had to do additional hacks to blend the FXAA with TAA so the blending seam wouldn't be that obvious.
    - as it really is about bypassing TAA, your example image would mean you'd omit TAA for everything besides the ball
    - for use case like in your image, it's better to either: use different AA or tweak TAA shaders hardcoded values from the TAA shader itself
     
    keeponshading likes this.
  4. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    rize, as always, thank you for the detailed reply. I am a bit surprised that you actually tested this in Unity and am impressed with your findings!

    As for handling ghosting, mind taking a look at this implementation?


    Hope to hear your opinion on it.
     
    keeponshading likes this.
  5. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I'm not really a rendering guy so can't really tell much about the fine details on individual approaches for TAA algos. I know playdeads TAA is here if you want to examine it: https://github.com/playdeadgames/temporal but afaik it's again very specificly designed to work on INSIDE so it might not cover all use cases. It also doesn't use Unity's own motion vectors and of course zero SRP support.

    From my experience with various engines that do TAA, regardless how good TAA you have (UE4 has currently one of the best ones IMO), it'll still ghost. It's just due to the temporal nature of the algo so you either need to avoid things that you know will ghost (noisy materials, big contrast objects moving on top of them etc) or do bunch of hacks like Amazon did in that article to hide the artifacts in places one knows it would ghost otherwise.
     
    jjejj87 and keeponshading like this.
  6. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Thanks for the insides.
     
  7. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Just to make this point more obvious, you can tweak the hardcoded define values from the beginning of this shader: https://github.com/Unity-Technologi...tProcessing/Shaders/TemporalAntialiasing.hlsl

    For these to stick, you have to put the whole HDRP package as you local package before you edit it but after that you get access to these values that you can tweak on the TAA shader:

    CLIP_AABB, RADIUS, FEEDBACK_MIN, FEEDBACK_MAX, SHARPEN, HDR_MAPUNMAP, CLAMP_MAX.

    Especially feedback min and max lets you dial the tresholds of the feedback so you can balance between no AA and when TAA kicks in when things are in motion.

    Do note that while these are hardcoded in the shader, any change you make to these will take effect immediately after you make Unity editor active again. So you can even tweak these in the text editor while the game is running in the Unity editor, you don't have to restart anything, just edit the shader and save it and you'll see the results as soon as Unity editor gets focus again.
     
    keeponshading likes this.
  8. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    After reading your post and link i am sure TAA should be integrated in Cinemachine.)
     
  9. Scanlab

    Scanlab

    Joined:
    Apr 27, 2014
    Posts:
    13
    @rz_0lento

    Thanks for this info. What do you mean by "put the whole HDRP package as your local package"? What are the steps to do that?
    Also, I noticed that the code has changed. What's the current process for controlling sharpening and other similar effects?
     
  10. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    HDRP 10 already exposes many of the tweaking values so you don't have to manually modify the shaders. TAA settings are in the camera.

    If you really want to do it though, basically you'd install HDRP package as normal but once it's installed, you'd go to your projects Library/PackageCache folder and move the HDRP package from it into your projects Packages folder. This will make it a local package which Unity can't edit / restore itself so you can tweak it locally without fear of losing your changes.