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:
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?
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:Custom Pass | High Definition RP | 10.2.2.
Can you post images of what your glitches look like? it may help us to identify the problem.
@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?
EDIT: actually it would work but require passing both RenderStateMask.Depth | RenderStateMask.Stencil for my case.