DrawRenderersCustomPass ignores alpha clipping if used with a Lit shader

Before posting an official bug, I just wanted to make sure this is not a duplicate or that there is some easy work-around.

Test setup (Unity 2022.1.13).

    1. A simple DrawRenderersCustomPass filtered for the “Flaura” Layer Mask.
    1. A camera with a culling mask excluding “Flaura”.
    1. A simple plane with the “Flaura” layer, rendered using the custom pass.

3.

Following are the results in the Game View.

First, we set the leaf plane’s material to use the Until shader:

Now, we simply switch to to the Lit shader:

And there you have it - alpha clipping no longer works in the custom pass.

I have tried all possible combinations of Injection Point and the various other dropdowns available in the custom pass settings. Alpha clipping never works.

Any ideas?

Thanks in advance!

1 Like

Hello,

I believe this is because in the HDRP Lit shader, for opaque objects we do the alpha clipping during the depth pre-pass and then we disable it for performance reasons.
In this situation, I think the best would be to add another draw renderers custom pass executed in the “After Depth And Normal” injection point that writes the depth of your alpha-clipped objects into HDRP depth buffer. Then you can disable the Override Depth toggle in the Draw Renderers custom pass.

Hello, can you please show with an example what needs to be done, otherwise I don’t quite understand

I think you can take a look at this example from the custom pass repo: https://github.com/alelievr/HDRP-Custom-Passes#render-with-normal-buffer (Rendering an object with multiple custom passes in depth, normal and color buffers).
Rendering an object in such a way will fix the alpha clip problems as well as other issues related to post processes.