Search Unity

SetReplacementShader / RenderWithShader with transparent materials, not writing to depth

Discussion in 'Shaders' started by Dreamback, Aug 20, 2018.

  1. Dreamback

    Dreamback

    Joined:
    Jul 29, 2016
    Posts:
    220
    I'm calling Camera.RenderWithShader with no tag, so it should affect everything in the screen. The replacement shader is a very simple fragment shader, just drawing each object with a solid color, and is one that will write to the depth buffer/texture - its render queue is "Geometry", it has ShadowSupport true, ZWrite On, and has a Fallback "Diffuse". But for any material that is transparent before the replacement, the replacement shader doesn't appear to be writing to depth.

    Any idea what I need to do to fix this?