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

Make unlit transparent object always render behind others

Discussion in 'Shaders' started by juliasser, Feb 16, 2022.

  1. juliasser


    Oct 13, 2021
    I'd like to have an unlit transparent object (brown) always render behind others, or at least behind objects inside. So far I could get it to work by adding

    "Queue" = "Transparent-1"

    ZWrite Off

    to the shader. Also I'm using this Stencil to not make the Object overlap with itself, so it's only one solid area:
    Stencil {
    Ref 10
    ReadMask 10
    Comp NotEqual
    Pass Replace

    Now I have an opaque object (green) INSIDE which I want to render in front. I added

    "Queue" = "Transparent" 

    to its shader. However, this results in various other problems which I'd like to avoid by just keeping it in the Opaque-Queue.

    Also, the green object should still be occluded by other objects, like this black cube.

    Is there some other solution to this problem?

    This is for a VR-Application so a solution with multiple cameras is probably quite difficult.