- Home /
How to convert world position of a pixel to a depth value? (shader)
My shader use a distance texture to calculate the world position of pixels. So far, i can make it get the correct world position, and make it correctly interact with the unity lighting system (even point light). and now i want to correctly interact with the depth so that i can do depth test, projecting or even shadow rendering. But i can't calculate the correct depth value.
Do you know how to convert world position of a pixel to a depth value?
I think that would be the Z value of your screen-space point. (that's the one you get when use use the UNITY_$$anonymous$$ATRIX_$$anonymous$$VP matrix.) Not sure about this though...grain of salt.
Your answer
![](https://koobas.hobune.stream/wayback/20220612101715im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get the world position from Depth buffer to main thread 1 Answer
Desaturating based on camera depth in an image effect? 0 Answers
How can I get seperate CameraDepthTextures for two different image effects. 0 Answers
Custom Transparency shader occasionally losing transparency? 1 Answer
How can I manage the ZDepth for a fade object- Shader Unity 2 Answers