Search Unity

Parallax Occluion Mapping AntiAliasing

Discussion in 'Shaders' started by sewy, Mar 6, 2019.

  1. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Hello everyone,

    I am working on the Parallax Occluion Mapping for VR (!).

    Everything works fine, except the monstrous aliasing problem (foto (from the internet)). By that I dont mean the visibility of layer transitions, but true aliasing on the edges.

    I've tried to do multiple samples of the whole paralax process and then weighted average of the samples on the edges, which blurs them. It works a bit, but it is heavy on computing (multiple samples of multiple layers) and the result is not that good.

    Due to VR, we cannot use any screen space AA.

    Is it possible to fix it with different approach?
    Is it possible to somehow feed it to the MSAA?

    Same problem occurs on the official HDRP/Lit material with pixel displacement.
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    Yep.

    Nope. MSAA only works on geometry edges.
    https://mynameismjp.wordpress.com/2012/10/24/msaa-overview/
    Because there are no geometry edges to test against mid triangle, there's nothing MSAA can help with.

    In shader multi/super sampling using offset ray directions is the only option. You should be able to get your ray pattern to match the one used by 4x MSAA, which is a rotated grid, sometimes called "four rooks". That should get you similar or better quality than MSAA would get, if it worked. The trick to reduce blurring is to make sure your offsets to the ray are still within the screen pixel boundaries. It also requires each ray does its full lighting calculation, so you can't use a surface shader here and get acceptable results.

    The only other solution is Temporal AA, which I hate for VR.
     
    sewy likes this.