Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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

    ElmarM

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

    c0d3_m0nk3y

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