Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Shader issue when trying to linearize the depth

Discussion in 'Editor & General Support' started by qidrokun, Mar 30, 2021.

  1. qidrokun

    qidrokun

    Joined:
    Nov 29, 2019
    Posts:
    13
    Hey, I'm just getting to shader programming and I'm absolutely not sure if this is how it's adviced to approach the issue of generating depth onto rendertexture of secondary camera (not main), but i've managed to get the non-linear value working nicely by using commandbuffers and sending it to rendertexture which is used at a shader to isolate the depth value. However when i try to linearize the depth I get wrong values due to the linear01depth dealing with apparently maincamera values instead of the camera i've used to render the actual image. I confirmed this suspicion by changing the maincameras far/near clipping planes and yes... it's how it works to my misery.

    If anyone knows how to go around this and utilize correct camera parameters without having to manually define properties for the equations. Or switching cameras around, I'd much appreciate the insight.

    Best regards,
    Qidrokun
     
unityunity