Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sample depth buffer in Forward Rendering without a separate prepass

Discussion in 'Graphics Experimental Previews' started by julienkay, Feb 28, 2019.

  1. julienkay

    julienkay

    Joined:
    Nov 12, 2013
    Posts:
    167
    I want to sample the depth buffer in a shader that runs after opaque objects have been rendered. I want to do this with Forward Rendering and without doing an additional prepass. (Which happens when you set Camera.depthTextureMode to 'Depth' on your camera.)

    If I understood things correctly, this is a thing that should technically be possible (at least on modern Windows platforms, which is the only thing I care about for now), but is currently not supported with the standard renderer in Unity. Can anyone confirm?

    I found these thoughts from @Aras on this topic from some time ago. At the end of the document he mentions Scriptable Render Loops as a possible solution.
    Has anyone tried to do this with SRP and can point me in the right direction here? Would I be able to do this with a custom SRP or does one of the built-in SRPs already support this?

    Thanks a lot in advance.
     
  2. julienkay

    julienkay

    Joined:
    Nov 12, 2013
    Posts:
    167