Shader "Infinity Code/Online Maps/Tileset Fade Shader" { Properties { _Color("Main Color", Color) = (1,1,1,1) _MainTex("Base (RGB) Trans (A)", 2D) = "white" {} _OverlayBackTex("Overlay Back Texture", 2D) = "black" {} _OverlayBackAlpha("Overlay Back Alpha", Range(0, 1)) = 1 _TrafficTex("Traffic Texture", 2D) = "black" {} _OverlayFrontTex("Overlay Front Texture", 2D) = "black" {} _OverlayFrontAlpha("Overlay Front Alpha", Range(0, 1)) = 1 } SubShader { Tags{ "Queue" = "Transparent-100" "IgnoreProjector" = "True" "RenderType" = "Transparent" } LOD 200 CGPROGRAM #pragma surface surf Lambert alpha sampler2D _MainTex; static const int _MaxSegments = 128; uniform int _CountSegments; uniform float4 _Segments[_MaxSegments * 2]; // [start, end, start, end, ...] uniform int _SegmentsThickness; uniform fixed4 _SegmentsColor; struct Input { float2 uv_MainTex; float3 worldPos; }; float sdf(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; float h = saturate(dot(pa, ba) / dot(ba, ba)); return length(pa - ba * h); } void surf(Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex); fixed3 rgb = c.rgb; const float2 wp = float2(IN.worldPos.x, IN.worldPos.z); [loop] for (int i = 0; i < _CountSegments; ++i) { float4 start = _Segments[i * 2]; float4 end = _Segments[i * 2 + 1]; float d = sdf(wp, start.xy, end.xy); if (d < _SegmentsThickness) { rgb = lerp(rgb, _SegmentsColor.rgb, _SegmentsColor.a); break; } } o.Albedo = rgb; o.Alpha = c.a; } ENDCG } Fallback "Transparent/Cutout/Diffuse" }