- Home /
Wrong Depth texture being passed into the shader.
Hi all,
I've been looking into an issue where I am reading the depth value from the _CameraDepthNormalsTexture in a shader to create a basic stencil of a rendered object. This object is set to a specific layer mask and the desired camera is set to render only that layer. Elsewhere in the scene there is another camera also set to render another single object that has also been set to a different specific layer. The issue that is occurring is that as soon as the second camera renders its object, its shader's _CameraDepthNormalsTexture property still contains the data of the first camera and not the current camera.
I am calling the shader from a Graphics.Blit() from within OnRenderObject() in a MonoBehaviour script that is a component on the two game objects that each contain the cameras in question.
If anyone has any ideas to shed some light on this issue, it would be greatly appreciated.