Shader "Carmen/SDF/Marker" { Properties { _MainTex ("SDF", 2D) = "white" {} _BorderColour ("Border Colour", Color) = (1.0, 1.0, 1.0, 1.0) _BorderSize ("Border Size", Range(0.05, 0.95)) = 0.95 _FillColour ("Fill Colour", Color) = (0.0, 0.0, 0.0, 1.0) _FillSize ("Fill Size", Range(0.05, 0.95)) = 0.66666666666666 } SubShader { Tags { "Queue"="Transparent" "RenderType" = "Transparent" } LOD 200 Pass { Cull Back Lighting Off Blend SrcAlpha OneMinusSrcAlpha Offset -1, -1 CGPROGRAM #include "UnityCG.cginc" #pragma target 4.5 #pragma vertex vert #pragma fragment frag UNITY_DECLARE_TEX2D(_MainTex); float4 _MainTex_ST; half4 _BorderColour; half _BorderSize; half4 _FillColour; half _FillSize; struct Data { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct V2F { float4 position : SV_POSITION; float2 uv : TEXCOORD0; }; V2F vert(Data v) { V2F o; o.position = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } fixed4 frag(V2F i) : SV_TARGET { half sdf_sample = UNITY_SAMPLE_TEX2D(_MainTex, i.uv).r; half border_halfchange = (abs(ddx(sdf_sample)) + abs(ddy(sdf_sample))) / 2.0; half border_loweredge = (1.0 - _BorderSize) - border_halfchange; half border_upperedge = (1.0 - _BorderSize) + border_halfchange; half border_mask = saturate((sdf_sample - border_loweredge) / (border_upperedge - border_loweredge)); half fill_halfchange = (abs(ddx(sdf_sample)) + abs(ddy(sdf_sample))) / 2.0; half fill_loweredge = (1.0 - _FillSize) - fill_halfchange; half fill_upperedge = (1.0 - _FillSize) + fill_halfchange; half fill_mask = saturate((sdf_sample - fill_loweredge) / (fill_upperedge - fill_loweredge)); half3 blend_colour = lerp(_BorderColour, _FillColour, fill_mask); return fixed4(blend_colour, border_mask); } ENDCG } } Fallback "VRChat/Mobile/Standard Lite" }