Game Development Reference
In-Depth Information
6.4.1 Reflection Vector Calculation
The direction of the reflection of light on a shiny surface (such as a mirror) fol-
lows the simple rule that the angle of incidence is equal to the angle of reflection.
As shown in Figure 6.5, this is the same as saying that the angle between the
normal vector N and the direction L pointing toward the incoming light is equal
to the angle between the normal vector and the direction R of the reflected light.
We assume that the vectors N and L have been normalized to unit length. To
derive a formula that gives us the reflection direction R in terms of the light di-
rection L and the normal vector N , we first calculate the component of L that is
perpendicular to the normal direction:
(
)
perp
N LL NLN .
=− ⋅
(6.89)
The vector R lies at twice the distance from L as does its projection onto the
normal vector N . We can thus express R as
RL L
LLNLN
NLN L
=−
=−
2perp
2
N
[
(
)
]
− ⋅
(
)
=⋅
2
.
(6.90)
N
(
)
LNLN
−⋅
(
)
L
NLN
R
αα
Figure 6.5. The direction of reflection R forms the same angle with the normal vector N
as the direction L pointing toward the incoming light. It is found by subtracting twice the
component of L that is perpendicular to N from L itself.