- Home /
How to get the depth from custom shader objects in fragement shader
Hey,
I tried all I know, and I think I only need a tag or something like that.
I want to write a DoF shader and for testing I show the depth as gray value.
This is the code in the shader:
float depth = Linear01Depth(tex2D(_CameraDepthTexture, input.projPos.xy/input.projPos.w).r);
and I also do this:
camera.depthTextureMode = DepthTextureMode.Depth;
I render the stuff as a post effect with this:
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination, material);
}
the material is created from shader.
If I change the RenderingPath to Deferred Lighting it works well, but if I use Forward, the screen is white. The shaders of the objects I render are custom, so if I change the shaders to standard ... e.g. Diffuse ... the forward-rendering will work.
I think I have to add something to my custom shaders ... but what?
Your answer
Follow this Question
Related Questions
Writing depth to render target / iOS 0 Answers
shader: color white after a precise z-value 1 Answer
Unity 5 fragment shader that writes custom depth into the depth texture 1 Answer
Rendering different shader when camera get near object 1 Answer
Why doesn't this shader work when using it with as a custom effect on the post processing stack 1 Answer