Shader "SuYou/Lightmap_Diffuse" { Properties { _MainTex ("Base", 2D) = "white" {} } CGINCLUDE sampler2D _MainTex; ENDCG SubShader { Tags { "RenderType"="Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON #include "UnityCG.cginc" 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); #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 }