- Home /
Use camera depth texture to find distance from camera
I realize that this must seem extremely basic, but I cannot seem to find any relevant information on the subject. If you believe this has already been answered, please read the rest of the question to make sure.
I am attempting to create my own Image Effect
which is similar to the DoF
effect, but there are some large enough differences that I cannot simply modify DoF
shader. I need to find the distance between the fragment and the camera. The tricky thing is that I also need to find the angle between that fragment and a specific fragment. This means that the distance must not be in the 0-1 range, but in the NearClip-FarClip
range.
In short, I need to know how to get a specific pixel from the depth texture, the camera frustum information, and the approximate world-space position of the fragment. Thoughts?
Your answer
Follow this Question
Related Questions
How to get depth texture and render texture from one camera 0 Answers
How to get the depth values of the camera view? 1 Answer
Mesh based volumetric lighting with RenderTexture 1 Answer
Culling Mask with Depth Occlusion 1 Answer
Easy way to render a texture, pixel perfectly, with a shader, and get the result? 0 Answers