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

Render custom depth texture in deferred shading?

Discussion in 'General Graphics' started by battou, Mar 11, 2015.

  1. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    222
    Seems like I cant render custom depth texture. I tried using Shader replacement on main camera, but figured out that in deffered shading replacements not working. so I created second camera with forward rendering, assigned render texture to it, set to render depth texture, assigned shader replacement from manual that uses
    UNITY_OUTPUT_DEPTH(i.depth) and tried to render to texture using this shader in LateUpdate, OnPreCull, OnPreRender, but it always renders black texture. What am I doing wrong? render texture wos created using RenderTexture.GetTemporary(Screen.width,Screen.height,16); Color render without shader replacement renders ok, but not depth.(
     
  2. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    222
    Found the problem. This method don't work if player set to DX11. Personally I consider this a bug.