- Home /
Is _CameraDepthNormalsTexture accesible in a Surface Shader?
I'm trying to render a surface that is aware of the depth & normals of the scene behind it. I've been successful getting depth info in a surface shader with float2 suv = IN.screenPos.xy / IN.screenPos.w; float depth = tex2D (_CameraDepthTexture, suv);
But when I enable DepthTextureMode.DepthNormals
on my camera and try to access normals & depth using DecodeDepthNormal(tex2D(_CameraDepthNormalTexture, suv ), depthValue, normalValues);
I get a flat gray depth texture / flat blue normal texture.
I've played with the UVs I feed DecodeDepthNormal
and consistently get the same results even if I experiment with scaling them up or down, leading me to believe that _CameraDepthNormalsTexture
is not built in time for me to read it in a surface shader, or that I am not setting it up properly.
I found a blog post about using _CameraDepthNormals
in a vert / frag shader as an image effect and I have been successful in implementing it there.