Shader "Unlit/UnlitAlphaWithFade" { Properties { _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _TexValue ("Texture Value", Range(0,1)) = 0.0 } SubShader { Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" } LOD 200 CGPROGRAM #pragma surface surf NoLighting fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) { fixed4 c; c.rgb = s.Albedo; c.a = s.Alpha; return c; } sampler2D _MainTex; uniform float _PlayerY = 0; struct Input { float2 uv_MainTex; float3 worldPos; }; void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex); half junk; half darkMult = IN.worldPos.y - (_PlayerY-1); half darkSmooth = modf(darkMult, junk)*8; //The multiplier here determines the smoothing between layers darkMult = (ceil(darkMult+2)/12)+.67; //Base the layer darkness off the player position and a scalar if(ceil(darkSmooth) == 0) //If near edge of current shading stage darkMult += 0.09 + modf(darkSmooth, junk)/12; //Use the second decimal place as a smoothing value between stages half alpha = (IN.worldPos.y - _PlayerY - 1.5)/3; if(darkMult > 1) darkMult = 1; if(darkMult < 0.15) darkMult = 0.15; if(alpha > 0.95) alpha = 0.95; if(alpha < 0) alpha = 0; if (IN.worldPos.y < _PlayerY-1) { o.Albedo = c.rgb * darkMult; } else { o.Albedo = c.rgb * .92; } if (IN.worldPos.y > _PlayerY + 1.5) { o.Alpha = c.a * (1-alpha); } else { o.Alpha = c.a; } } ENDCG Pass { Cull Back Lighting Off Alphatest Greater [_Cutoff] SetTexture [_MainTex] { combine texture } } Pass { Cull Front Lighting Off Alphatest Greater [_Cutoff] SetTexture [_MainTex] { combine texture } } } }