- 系统内置漫反射Shader "Diffuse"
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject' Shader "LXC/05 Diffuse Fragment" { Properties{ _Diffuse("Diffuse Color",Color) = (1,1,1,1) } SubShader { Pass{ Tags{ "LightMode" = "ForwardBase" } CGPROGRAM #include "Lighting.cginc" #pragma vertex vert #pragma fragment frag fixed4 _Diffuse; struct a2v { float4 vertex:POSITION; float3 normal:NORMAL; }; struct v2f { float4 position:SV_POSITION; fixed3 worldNormalDir : COLOR0; }; v2f vert(a2v v) { v2f f; f.position = UnityObjectToClipPos(v.vertex); f.worldNormalDir = mul(v.normal, (float3x3) unity_WorldToObject); return f; } fixed4 frag(v2f f) :SV_Target{ fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.rgb; fixed3 normalDir = normalize(f.worldNormalDir); //没有发现需要传递 fixed3 lightDir = normalize(_WorldSpaceLightPos0.xyz); fixed3 diffuse = _LightColor0.rgb * max(dot(normalDir,lightDir),0)*_Diffuse.rgb; fixed3 tempColor = diffuse + ambient; return fixed4(tempColor,1); } ENDCG } } Fallback "Diffuse" //系统内置漫反射Shader }
Shader-漫反射(像素实现)
猜你喜欢
转载自blog.csdn.net/qq_42459006/article/details/84109263
今日推荐
周排行