Search Unity

Bug DrawRenderersCustomPass ignores alpha clipping if used with a Lit shader

Discussion in 'High Definition Render Pipeline' started by mgeorgedeveloper, Dec 23, 2022.

  1. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    327
    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.
    - 2. A camera with a culling mask excluding "Flaura".
    - 3. A simple plane with the "Flaura" layer, rendered using the custom pass.

    1.
    custom-pass-alpha-issue-1.png

    2.
    custom-pass-alpha-issue-2.png

    3. custom-pass-alpha-issue-3.png


    Following are the results in the Game View.

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

    custom-pass-alpha-issue-4.png

    Now, we simply switch to to the Lit shader:

    custom-pass-alpha-issue-5.png

    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!
     
    Last edited: Dec 23, 2022
  2. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
    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.
     
  3. Evgeno

    Evgeno

    Joined:
    Sep 8, 2014
    Posts:
    57
    Hello, can you please show with an example what needs to be done, otherwise I don’t quite understand
     
  4. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
    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.