Created
November 27, 2020 08:52
-
-
Save andijakl/736a189c1e4be3cd63ea39cfba48a1e8 to your computer and use it in GitHub Desktop.
Part of the AR Foundation DepthGradient shader for Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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