fixed3 worldNormal = normalize(i.worldNormal);

 

fixed3 worldLightDir = normalize(UnityWorldSpaceLightDir(i.worldPos));

观察方向

fixed3 viewDir = normalize(UnityWorldSpaceViewDir(i.worldPos));

fixed3 viewDir = normalize(_WorldSpaceCameraPos.xyz-i.worldPos);

Unity Shader笔记之Blinn—Phong光照模型高光代码理解

fixed3 halfDir = normalize(worldLightDir + viewDir);

 

fixed3 specular = _LightColor0.rgb * _Specular.rgb * pow(max(0, dot(worldNormal, halfDir)), _Gloss);
                

相关文章: