Diffuse (Lambert)
- Lum = C * max (0, cos (L, N))
- Lum: difuso brillo reflectante.
- C: difusa intensidad de reflexión (difusa de color reflectante).
- L: dirección de la luz incidente.
- N: dirección normal.
Espejo de transmisión (Phong)
- Lum = C * pow (max (0, cos (R, V)), brillo)
- Lum: alto brillo.
- C: intensidad de la luz alta (color de realce).
- R: la dirección de la luz reflejada.
- V: la dirección de visión.
- Brillo: suavidad espejo.
Vector de tamaño mitad (BlinnPhong)
- Lum = C * pow (max (0, cos (H, N)), brillo)
- Lum: alto brillo.
- C: intensidad de la luz alta (color de realce).
- H: vector de tamaño mitad.
- N: dirección normal.
- Brillo: suavidad espejo.
iluminación de la función dentro de la Unidad
- Forward bajo función de iluminación difusa:
inline fixed4 LightingLambert(SurfaceOutput s, fixed3 lightDir, fixed atten){
fixed diff = max(0, dot(s.Normal, lightDir));
fixed4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}
- funciones hacia delante a gran luz:
inline fixed4 LightingBlinnPhong(SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten){
half3 h = normalize(lightDir + viewDir);
fixed diff = max(0, dot(s.Normal, lightDir));
float nh = max(0, dot(s.Normal, h));
float spec = pow(nh, s.Specular * 128.0) * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten * 2);
c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
return c;
}