Search Unity

Question Depth prepass with deferred questions (decals, motion vectors)

Discussion in 'High Definition Render Pipeline' started by sqallpl, Nov 2, 2022.

  1. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    Unity 2021.2
    HDRP 12.1.5

    When I use decals should the "Depth Prepass within Deferred" option be enabled or disabled in the HDRP Global Settings? If I don't want to use decals on all materials should this option be enabled or disabled? HDRP sample uses decals and has this option disabled but if I disable 'receive decals' on any material (with "Depth Prepass within Deferred" disabled) it has problems with motion vectors and effects like TAA/DLSS.

    HDRP documentation says that: "If you enable Decals then HDRP forces a depth prepass and you can not disable this feature.". The thing is even if decals are enabled it's still possible to enable/disable the checkbox.
    Does it mean that if decals are enabled this option is ignored and Depth Prepass is always performed for all renderers? I was curious so I've checked the HDRP sample project and this option is disabled there.

    HDRP Decal documentation says that: "HDRP renders Material depth in a Depth Prepass to apply decals to opaque Materials. This increases resource use on the CPU. Only Materials that have the Receive Decals property enabled render in the Depth Prepass, unless you force a full Depth Prepass. To prevent HDRP from rendering a Material which shouldn't receive Decals in the Depth Prepas:
    1. Open the Material assigned to a Mesh Renderer or Terrain that you do not want to display decals on.

    2. Disable the Receive Decals property.
    "

    How do I know if the "full Depth Prepass" is forced? Is it related to the "Depth prepass with deferred" option?

    I assumed that "Depth Prepass within Deferred" forces full depth prepass so I disabled it. Then I disabled 'receive decals' for some materials to test if everything works fine. I've noticed some weird artifacts on objects that use these materials when moving the camera. I've noticed that it has something to do with motion vectors because those artifacts was related to TAA/DLSS and probably other screen space effects that use motion vectors. Looks like materials that have 'receive decals' disabled have some problems with motion vectors when the "Depth Prepass within Deferred" option is disabled. I created new project with HDRP sample to check if there is something wrong in my project but I found that it happens in HDRP sample too. You can just disable 'receive decals' on any material in the HDRP sample scene to see this problem.

    Here is a sample video. I've used one of the wall materials from the sample. Left cube material has 'receive decals' disabled while right cube material has 'receive decals' enabled. TAA is enabled. I'ts HDRP sample scene with default settings so the problem is visible just by disabling decals for a material.



    v5.jpg

    v6.jpg



    Here is the ball from the HDRP sample. It has two materials. Rubber (Unity logo) and brass. On the motion vectors debug view I'm moving the camera horizontally.

    mv3.jpg

    Both materials have 'receive decal' options enabled.

    mv2.jpg

    Rubber material with Unity logo has 'receive decals' enabled while brass material has this option disabled.

    mv1.jpg
     
    Last edited: Nov 2, 2022
    alexandre-fiset likes this.