Search Unity

How to ovewrite camera depth normal texture

Discussion in 'Shaders' started by neitron, Jun 29, 2017.

  1. neitron

    neitron

    Joined:
    Sep 14, 2014
    Posts:
    14
    Hi, everyone. I know that depth buffer and camera depth texture are different things. Just output SV_Depth from fragment shader enough for approximate ZTest. For writing to the depth camera I have to use ShadowCaster pass. I have a sprite with extra depth and normal maps, I use it for lighting effects. So, I have next questions:

    1 - how to properly convert depth values from a custom texture to the camera depth texture range. My formulas based on the ZBufferParams built-in variable (wich is based on camera`s near and far planes), but something incorrect (wrong). I suppose to get the same behaviour as with 3d cube (for example) when you are changing the distance of the far plane.

    2 - how to output normals (custom normals) at all.

    I'll be very grateful for any help )