|
Shader "Test/LightmapSurface" {
Properties { _MainTex("Texture", 2D) = "white" {} [NoScaleOffset] _AddTex("Add texture", 2D) = "white" {} [KeywordEnum(None, Add, Multiply, Screen)] _Overlay("Overlay mode", Float) = 0 }
SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM
#pragma surface surf Lambert vertex:vert noforwardadd noambient #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _OVERLAY_NONE _OVERLAY_ADD _OVERLAY_MULTIPLY _OVERLAY_SCREEN
struct Input { float2 uv_MainTex; float2 lm; };
sampler2D _MainTex; // sampler2D unity_Lightmap; // float4 unity_LightmapST;
sampler _AddTex;
void vert(inout appdata_full v, out Input o)
{ UNITY_INITIALIZE_OUTPUT(Input, o); o.lm = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; }
void surf(Input IN, inout SurfaceOutput o) {
fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb; o.Albedo = c.rgb; fixed3 ad = tex2D(_AddTex, IN.lm).rgb; # ifdef LIGHTMAP_ON fixed3 lm = UNITY_SAMPLE_TEX2D(unity_Lightmap, IN.lm); o.Albedo *= lm; #if _OVERLAY_ADD o.Albedo += ad; #elif _OVERLAY_MULTIPLY o.Albedo *= ad; #elif _OVERLAY_SCREEN o.Albedo = (1-(1- o.Albedo)*(1-ad)); #endif #endif }
ENDCG } Fallback "Diffuse" }
|