标准光照模型把进入摄像机的光线分成自发光、环境光、漫反射、高光反射四个部分,每个部分使用一种方法计算贡献度

 标准光照 = 环境光 + (漫反射 + 高光反射)* 光照衰减

反射率:fixed3 albedo = tex2D(_MainTex, i.uv.xy) * _Color.rgb;

环境光:fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * albedo;

漫反射:

  兰伯特:fixed3 diffuse = _LightColor0.rgb * albedo * saturate(dot(worldNormal或bump, lightDir));

      lightDir:fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));

  半兰伯特:fixed3 diffuse = _LightColor0.rgb * albedo * (dot(worldNormal或bump, lightDir) * 0.5 + 0.5);

高光反射:

  Phong:fixed3 specular = _LightColor0.rgb * _Specular.rgb * pow(saturate(dot(viewDir, reflectDir)), _Gloss);

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

      reflectDir:fixed3 reflectDir = normalize(reflect(-worldLight, worldNormal或bump));

      reflect()方法 = 2 *  dot(归一化法线方向, 归一化光源方向) * 归一化法线方向 - 归一化的光源方向

  Blinn-Phong:fixed3 specular = _LightColor0.rgb * _Specular.rgb * pow(saturate(dot(worldNormal或bump, halfDir)), _Gloss);

      halfDir:fixed3 halfDir = normalize(viewDir + worldLight);

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

最终颜色:fixed4 color = fixed4(ambient + (diffuse + specular) * atten, 1);