Shader "SuYou/Lightmap_Cutout" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base", 2D) = "white" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } CGINCLUDE half _Cutoff; sampler2D _MainTex; ENDCG SubShader { Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} Pass { CGPROGRAM #include "UnityCG.cginc" #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON fixed4 _Color; struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; struct v2f { half4 pos : SV_POSITION; half2 uv : TEXCOORD0; #ifdef LIGHTMAP_ON half2 uv2 : TEXCOORD1; #endif UNITY_FOG_COORDS(2) }; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.pos = UnityObjectToClipPos (v.vertex); #ifdef LIGHTMAP_ON o.uv = v.texcoord; o.uv2 = v.texcoord1 * unity_LightmapST.xy + unity_LightmapST.zw; #else o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); #endif UNITY_TRANSFER_FOG(o,o.pos); return o; } fixed4 frag (v2f i) : COLOR0 { fixed4 tex = tex2D (_MainTex, i.uv) * _Color; clip( tex.a - _Cutoff ); #ifdef LIGHTMAP_ON fixed3 lm = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap,i.uv2)); tex.rgb *= lm; #endif UNITY_APPLY_FOG(i.fogCoord, tex); return tex; } ENDCG } } FallBack Off }