Part of the AR Foundation DepthGradient shader for Unity
fragment_output frag (v2f i) | |
{ | |
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); | |
// Sample the environment depth (in meters). | |
float envDistance = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r; | |
real lerpFactor = (envDistance - _MinDistance) / (_MaxDistance - _MinDistance); | |
real hue = lerp(0.70h, -0.15h, saturate(lerpFactor)); | |
if (hue < 0.0h) | |
{ | |
hue += 1.0h; | |
} | |
real3 color = real3(hue, 0.9h, 0.6h); | |
fragment_output o; | |
o.color = real4(HSVtoRGB(color), 1.0h); | |
return o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment