Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Semi-Transparent Shader blocking skybox

Discussion in 'Shaders' started by CDF, Jun 16, 2017.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,307
    So I've got a semi-transparent surface shader with ZWrite=On.
    The problem I'm having is (I think) the object is writing to the depth buffer which is preventing the skybox on the camera from rendering at that position. I need ZWrite On though, because I want scene objects behind this semi-transparent shader to be blocked.

    The solution I have so far is use 2 cameras.

    1st camera just clears with skybox, doesn't rendering anything else (culling = None)
    2nd camera renders scene with clearFlags = Depth Only

    This works, but was wondering if there's some method I can use in the shader rather than have 2 cameras... Or can I manually draw the camera with skybox only, then render the scene after?

    **Strange thing is, everything looks correct in the Scene View, my guess is the scene camera is doing more than the game camera in terms of clearing
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,307
    I guess this is my problem:

    skybox.jpg
     
  3. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,307
    damn, my queue was set to AlphaTest, setting to Transparent works, but no shadows anymore.

    :(

    Still, If there's a way to render a semi-transparent object after a skybox but with shadows I'd love to know. I'm thinking manually drawing the camera 2 times with different clear flags might work
     
    Last edited: Jun 16, 2017