Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Rendering Order Issue with HDRP Opaque Materials Using Alpha Clipping When Lights are On

Discussion in 'Editor & General Support' started by Gloraver, Nov 10, 2023.

  1. Gloraver

    Gloraver

    Joined:
    Aug 5, 2015
    Posts:
    3
    Greetings, Unity Community,

    I'm seeking advice on a rendering order problem within Unity's HDRP. I have a mesh with multiple materials that are set to opaque but utilize alpha clipping to achieve transparency effects. This setup renders perfectly when the scene's lighting is disabled; however, as soon as the lights are turned on, some materials don't render correctly—some textures that should be behind others (in terms of depth) are rendered on top.

    Here are the specifics of my setup:

    • Shader: HDRP/Lit, with materials set to opaque for alpha clipping functionality.
    • Problem: Proper rendering order with lights off, incorrect rendering order with lights on—suggesting a depth sorting issue affected by lighting.
    Here's what I've verified so far:

    • Alpha clipping is enabled and configured.
    • 'Receive Shadows' and 'Receive SSR' are both enabled.
    • No explicit render queue manipulation seems possible in HDRP for these materials.
    I'm trying to understand if this is a known limitation with alpha clipping on opaque materials in HDRP when lit or if there's a workaround I might not be aware of. Has anyone else encountered this, and are there best practices for maintaining the correct rendering order with these settings?

    Any insights or guidance would be greatly appreciated!

    Thank you for your time and help!
     
  2. Gloraver

    Gloraver

    Joined:
    Aug 5, 2015
    Posts:
    3
    Hello again, Unity Community,

    I wanted to share a development in my situation and seek further understanding or validation of the solution. As previously discussed, I had an issue with the rendering order of materials on a mesh using the HDRP/Lit shader with alpha clipping—textures were sorting incorrectly when the scene lighting was on.

    Update: I found that by creating a base opaque texture that contains all the layers and applying it to the mesh first, the rendering order works correctly when I then apply transparent materials on top of this base.

    Here are some follow-up questions I have:

    • Why does having a base opaque texture with all layers improve the depth sorting of additional transparent textures?
    • Is this a common practice or a workaround that inadvertently solves a more profound issue in HDRP's handling of transparency and lighting?
    • Could this method lead to potential performance hits or other rendering issues I should be aware of?
    I'm curious to know if others have used this technique and what the underlying mechanics are that make this effective. Any additional insights into why this approach works and its implications would be greatly appreciated.

    Thank you once again for your collective wisdom!