Classical Phong Empirical Local Lighting Model

Classical Phong Local Lighting Model at a Point, Q, on a Surface ⎧
⎪
i ⎨⎪
⎩
⎛
⎜
⎜⎝
⎞
⎟
i ⎟⎠
IQ = ka *La + ∑ f Q L kd * n̂⋅ l̂ + ks * r̂i ⋅v̂
i
⎛
i ⎜⎝
⎞
⎟
⎠
⎛
⎜
⎝
⎞
⎟
⎠
m⎫
⎪
⎬
⎪
⎭
Term Type Variable in shader ka rgb vec3 ka
Fraction of incident ambient light that is reflected; oftentimes ka = kd kd rgb
vec3 kd
Fraction of incident light that is diffusely reflected ks rgb
vec3 ks
Fraction of incident light that is specularly reflected La rgb vec3 globalAmbient
Li rgb vec3 lightStrength[max]
fi(Q) float n̂ vector Li,xyzw xyzw float atten(i, Q)
vec3 ec_nHat
vec4 p_ecLightPos[max]
Notes Amount of ambient light in the environment Strength of ith light source Function that computes the attenuation for light source i at point Q. Unit normal to the surface at Q (computed from wcNormal) Projective space description of light source placement. (Used in next row.) (
)
(
)
l̂i vector
vec3 liHat
Computed* unit normal to source i: l̂i = normalize Li,xyz − Q ‡ or l̂i = normalize Li,xyz § r̂i vector
vec3 riHat
Computed* unit vector in primary reflection direction for light source i v̂ vector
vec3 vHat
Computed* unit vector towards the eye; if perspective: –normalize(Q) – Why? If orthogonal: (0, 0, 1); if oblique: (?, ?, ?). m scalar float m
Specular coefficient (m>0; m<10 è only slightly glossy; m>25 è fairly glossy) *Computed in EC; Q is p_ecPosition (from mcPosition); L
i,xyzw is p_ecLightPos; ‡
if L
§ if L
i,xyzw=(x, y, z, 1);
è Equation evaluated in (rgb) space; Alpha (translucency) appended to fragColor in fragment shader. i,xyzw=(x, y, z, 0);