Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question URP > _QueueOffset is ignored by objects with transparent material

Discussion in 'Shaders' started by novaVision, May 10, 2024.

  1. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    Could someone explain me this, please?

    Intro - molecules are separate objects and have 1 URP Lit shared material with _QueueOffset = 0. I am changing the Transparent/Opaque mode runtime according to camera distance for smooth Fade In/Out effect.
    Glass has URP Lit material with _QueueOffset = 1.

    sample.png
    Top image - molecules with Opaque URP Lit material behind the glass. That's how it supposed to be.
    Bottom image - same molecules with the same material, but set to Transparent mode with alpha ~0.9f.

    Why are the molecules rendered "before" the glass? Looks like some kind of Z-fighting. For some reason glass _QueueOffset +1 doesn't do anything.

    The offset works only in 1 case - in Editor, if I slide the material value runtime, while the molecules are visible. Doesn't work in any other case - not by changing by script, not by predefined material parameters.

    Seems it shouldn't be like that.