Search Unity

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:
    670
  4. ElmarM

    ElmarM

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

    c0d3_m0nk3y

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