Search Unity

Feature Request Custom Pass: can you render RendererListDesc without overrideMaterial?

Discussion in 'High Definition Render Pipeline' started by bitinn, Jan 25, 2021.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi Unity Team,

    Is it possible to left overrideMaterial in RendererListDesc untouched? As in render using existing Materials?

    I am trying to adapt the SeeThrough example from the HDRP sample repo:

    https://github.com/alelievr/HDRP-Custom-Passes/tree/master/Assets/CustomPasses/SeeThrough

    But seems like unless I pass an Unlit material to overrideMaterial, the shading glitches: I am assuming there is a limitation here, but no one from HDRP team has commented on this detail, can you clarify?

    Thx! (I am on HDRP 7.5 and Unity 2019 LTS)
     
  2. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    263
    Hello,

    Yes, it's supposed to work. When you leave the overrideMaterial to null, the rendering uses the renderer's material with the shader pass specified in the passNames field. This often leads to the same object being rendering twice in the camera and causes z-fight or other similar artifacts, that's why it's recommended to only render the object in the custom pass and not in the camera (using layers).

    Something worth noting is that on certain injection points (like After Opaque Depth And Normal) you can't render Lit objects because the lighting buffers are not yet created, you can see this table for all injection points:https://docs.unity3d.com/Packages/c...al/Custom-Pass.html#drawrenderers-custom-pass.

    Can you post images of what your glitches look like? it may help us to identify the problem.
     
    bitinn likes this.
  3. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Thx, I realize the problem is mostly because I render them without proper PerObjectData for Lit shader. A good example could be found at:

    https://github.com/alelievr/HDRP-Cu...er/Assets/CustomPasses/RenderWithNormalBuffer
    https://docs.unity3d.com/Packages/c...stom-Pass.html#scripting-example-outline-pass

    Once I have done that, the render is mostly fine.
     
  4. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    @antoinel_unity Another tricky thing that I don't see the doc mentions:

    IF we pass the stateBlock directly with RenderStateBlock containing mask and stencilState, the stencil effect doesn't seem to work anymore.

    We have to first create the RendererListDesc with a RenderStateBlock with depthState only, then read the stateBlock and apply the mask and stencilState afterwards.

    I am assuming RendererListDesc adds some default states to stateBlock, and by passing the mask and stencilState we breaks them?

    https://github.com/alelievr/HDRP-Cu...CustomPasses/SeeThrough/SeeThrough.cs#L69-L75

    EDIT: actually it would work but require passing both RenderStateMask.Depth | RenderStateMask.Stencil for my case.
     
    Last edited: Jan 26, 2021