i
i
i
i
i
i
i
i
9.3. Reflections 387
on the reflected object. The conclusion that can be drawn from this prin-
ciple is that a reflection can be rendered by creating a copy of the object,
transforming it into the reflected position, and rendering it from there. To
achieve correct lighting, light sources have to be reflected in the plane as
well, with respect to both position and direction [892, 957].
If for a moment we assume that the reflecting plane has a normal,
n =(0, 1, 0), and that it goes through the origin, then the matrix that
reflects in this plane is simply this mirror scaling matrix: S(1, −1, 1). For
the general case, we derive the reflection matrix M,giventhenormalof
the reflector n and some point p on the reflector plane. Since we know
how to reflect in the plane y = 0, the idea is to transform the plane into
y = 0, then perform the simple scaling, and finally transform back. The
concatenation of these matrices yields M.
First, we have to translate the plane so that it passes through the
origin, which is done with a translation matrix: T(−p). Then the normal
of the reflector plane, n, is rotated so that it becomes parallel to the y-
axis: (0, 1, 0). This can be done with a rotation from n to (0, 1, 0) using
R(n, (0, 1, 0)) (see Section 4.3.2). The concatenation of these operations is
called F:
F = R(n, (0, 1, 0))T(−p). (9.24)
After that, the reflector plane has become aligned with the plane y =0,
andthenscaling,S(1, −1, 1), is performed; finally, we transform back with
F
−1
.Thus,M is constructed as follows:
M = F
−1
S(1, −1, 1)
T
F. (9.25)
Note that this matrix has to be recomputed if the position or orientation
of the reflector surface changes.
The scene is rendered by first drawing the objects to be reflected (trans-
formed by M), followed by drawing the rest of the scene with the reflector
included. An example of the results of this process appear in Figure 9.42.
An equivalent method is to instead reflect the viewer’s position and orienta-
tion through the mirror to the opposite side of the reflector. The advantage
of moving the viewer is that none of the geometry has to be manipulated
before being sent down to form the reflection [492, 849, 957]. In either case,
care must be taken with properly setting backface culling for the reflection
pass, as the use of a reflection matrix will normally flip the sense needed.
The reflector has to be partially transparent, so that the reflection is vis-
ible. As such, the transparency acts like a kind of reflectivity factor; the
reflector appears more reflective with increasing transparency.
However, sometimes the reflections can be rendered incorrectly, as in
the left part of Figure 9.43. This happens because the reflected geometry
can appear at places where there is no reflector geometry.Inotherwords,