I don’t want to let the grass appears local dimming, custom a lighting model in surface shaders
, it is ok.But after baking, shadowis wrong.Who knows why?
Shader "Custom/Test" {
Properties{
_MainTex("Texture", 2D) = "white" {}
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader{
Tags{ "RenderType" = "Opaque" }
Cull Off
CGPROGRAM
#pragma surface surf MyLight
#include "Lighting.cginc"
inline fixed4 UnityMyBlinnPhongLight(SurfaceOutput s, half3 viewDir, UnityLight light)
{
fixed4 c;
c.rgb = s.Albedo * light.color;
c.a = s.Alpha;
return c;
}
inline fixed4 LightingMyLight(SurfaceOutput s, half3 viewDir, UnityGI gi)
{
fixed4 c;
c = UnityMyBlinnPhongLight(s, viewDir, gi.light);
#if defined(DIRLIGHTMAP_SEPARATE)
#ifdef LIGHTMAP_ON
c += UnityMyBlinnPhongLight(s, viewDir, gi.light2);
#endif
#ifdef DYNAMICLIGHTMAP_ON
c += UnityMyBlinnPhongLight(s, viewDir, gi.light3);
#endif
#endif
#ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
c.rgb += s.Albedo * gi.indirect.diffuse;
#endif
return c;
}
inline void LightingMyLight_GI(SurfaceOutput s, UnityGIInput data, inout UnityGI gi)
{
LightingBlinnPhong_GI(s, data, gi);
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
half _Cutoff;
void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
clip(c.a - _Cutoff);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback Off
}

