- Home /
Shader - UNITY_SAMPLE_DEPTH function
I've been trying to find more info on this build in shader function "UNITY_SAMPLE_DEPTH" but internet behaves as if this function never existed, not even Unity themselves dont document this function...
- The input params
- The output value, its type and what it actually contains
I would be grateful to anyone who can shine more light onto this misterious fucntionfor me.
Answer by $$anonymous$$ · Jun 03, 2018 at 11:47 AM
Okey seems like function UNITY_SAMPLE_DEPTH is not even needed. Just use tex2Dproj or tex2D with NDC coordinates and then LinearEyeDepth function to transform non linear depth data to linear scale that's it :)
Answer by zergnick · May 29, 2018 at 02:39 AM
float depth = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, uv));
I don't know much about shader, and I hope this may help you.
Today I've found the example of :
float depth = UNITY_SA$$anonymous$$PLE_DEPTH(tex2Dproj(_CameraDepthTexture, uv));
where they use tex2Dproj ins$$anonymous$$d of tex2D you have shown. Which one should be used and when?