Graphics Reference
In-Depth Information
Note: In Example 8-2, we multiply the material colors (ambient, diffuse,
and specular) with the light colors. This is fine if we are computing
the lighting equation for only one light. If we have to compute the
lighting equation for multiple lights, however, we should compute
the ambient, diffuse, and specular values for each light and then
compute the final vertex color by multiplying the material ambient,
diffuse, and specular colors with appropriate computed terms and
then summing them to generate a per-vertex color.
A point light is a light source that emanates light in all directions from a
position in space. A point light is given by a position vector ( x , y , z , w ),
where w ≠ 0. The point light shines evenly in all directions but its intensity
falls off (i.e., becomes attenuated) based on the distance from the light to
the object. This attenuation is computed using the following equation:
distance attenuation
=
1/(
K
+
K
×
||
VP
||
+
K
×
||
VP
|| )
2
0
1
light
2
light
where K 0 , K 1 , and K 2 are the constant, linear, and quadratic attenuation
factors, respectively.
A spotlight is a light source with both a position and a direction that
simulates a cone of light emitted from a position ( P light ) in a direction
(given by spot direction ). Figure 8-4 describes the terms that are needed in
computing the lighting equation for a spotlight.
P eye
N
0 1 = 0 2
H
0 1
spot cutoff angle
0 2
spot direction
V
P light
Figure 8-4
Geometric Factors in Computing Lighting Equation for a Spotlight
The intensity of the emitted light is attenuated by a spot cutoff factor
based on the angle from the center of the cone. The angle away from
the center axis of the cone is computed as the dot product of VP light and
 
Search WWH ::




Custom Search