Game Development Reference
In-Depth Information
Figure 10.21
Constructing the reflection
vector
r
Of the four vectors, the first three are inherent degrees of freedom of
the problem, and the reflection vector
r
is a derived quantity and must be
computed. The geometry is shown in Figure 10.21.
As you can see, the reflection vector can be computed by
Computing the reflection
vector is a popular job
interview question
r
= 2(
n
l
)
n
−
l
.
(10.10)
There are many interviewers for whom this equation is a favorite topic,
which is why we have displayed it on a line by itself, despite the fact that
it would have fit perfectly fine inline in the paragraph. A reader seeking a
job in the video game industry is advised to fully digest Figure 10.21, to be
able to produce Equation (10.10) under pressure. Notice that if we assume
n
and
l
are unit vectors, then
r
will be as well.
Now that we know
r
, we can compute the specular contribution by using
the Phong model for specular reflection (Equation (10.11)).
The Phong Model for Specular Reflection
c
spec
= (
s
spec
⊗
m
spec
) (cosθ)
m
gls
= (
s
spec
⊗
m
spec
) (
v
r
)
m
gls
. (10.11)
In this formula and elsewhere in this topic, the symbol ⊗ denotes compo-
nentwise multiplication of colors. Let's look at the inputs to this formula
in more detail.
First, let's consider m
gls
, which is the glossiness of the material, also
known as the Phong exponent, specular exponent, or just as the material
shininess. This controls how wide the “hotspot” is—a smaller m
gls
produces
a larger, more gradual falloff from the hotspot, and a larger m
gls
produces a
Search WWH ::
Custom Search