【顶点漫反射计算】
v2f vert (appdata_base v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); //获取环境光 fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz; fixed3 worldNormal = UnityObjectToWorldNormal( v.normal); fixed3 worldLight = normalize(_WorldSpaceLightPos0.xyz); fixed3 diffuse = _LightColor0.rgb * _Diffuse.rgb * max(0, dot(worldNormal,worldLight)); //漫反射部分和环境光相加 o.color = diffuse + ambient; return o; }