Unity——基于ShaderLab实现光照系统 (4)

要求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即可;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgxzfy.html