要求v2f中顶点坐标变量名必须是pos;
Tags { "LightMode"="ForwardBase" } CGPROGRAM #pragma multi_compile_fwdbase #include "Lighting.cginc" #include "AutoLight.cginc" struct v2f { float4 pos : SV_POSITION; SHADOW_COORDS(2) }; v2f vert (appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); TRANSFER_SHADOW(o); return o; } fixed4 frag (v2f i) : SV_Target { fixed atten = 1.0; fixed shadow = SHADOW_ATTENUATION(i); return fixed4((ambient+ diffuse + specular)*atten*shadow,1.0); } 3.透明物体阴影处理CastShadows——改成Two Sides即可;