- Home /
Distance from pixel to camera in shader
Hey all. I'm fairly new to Shader code in Unity, so forgive me if my question is too vague. I would like to have an image effect (specifically the bloom) be a function of the distance to the camera, where the close objects get more bloom.
I've tried using the functions on this page: http://docs.unity3d.com/Manual/SL-DepthTextures.html
I placed the UNITY_TRANSFER_DEPTH in the vertex function in the Unity bloom shader, and thought that putting DECODE_EYEDEPTH in the fragment function would allow me to access the distance of the camera to the pixel. When I used it to control the bloom intensity it did not seem to be a function of distance.
Then in the Unity depth of field shader, they use SAMPLE_DEPTH_TEXTURE and Linear01Depth in the fragment function for what I'm assuming is a similar reason.
I'm having trouble finding documentation on any of these functions, and playing around with their results isn't getting me very far, please help!