Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to Get the depth Texture for each camera on HDRP or URP

Discussion in 'General Graphics' started by aqualamp, Jun 13, 2021.

  1. aqualamp

    aqualamp

    Joined:
    Apr 30, 2021
    Posts:
    1
    Thanks for taking a look. This is my first post.

    Is there a way to write out the per-camera depth to a Render Texture in HDRP or URP ?

    If it was a legacy pipeline, I would have written out the _CameraDepthTexture to the render target like this from a #C script through a shader.

     private void OnRenderImage(RenderTexture source, RenderTexture dest)
    {
    Graphics.Blit(source, dest, _material);
    }

    Alternatively,I could use a CommundBuffer to write out the texture at the appropriate stage.

    However, for HDRP or URP, I think there is a no way to get the depth for each camera, because of the graphics pipeline specification.

    I imagine this is because the way to get the DepthBuffer depends on the post-effects, so we can only get the DepthBuffer of the final rendered result.

    I've been investigating for about a week and have come to this conclusion.

    However, if there is some other way, please let me know.

    Thanks!
     
  2. ElmarM

    ElmarM

    Joined:
    Apr 27, 2022
    Posts:
    5
    Did you ever find a solution for this?
     
  3. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    560
  4. ElmarM

    ElmarM

    Joined:
    Apr 27, 2022
    Posts:
    5
  5. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    560
    I don't know, sorry.