Next: Interreflections
Up: 9.3.1 Planar Reflectors
Previous: Planar Reflections and Refractions
A technique similar to the stencil buffer technique uses texture
mapping. The first pass is identical to the first pass of the
previous technique: we draw the reflected scene. After drawing the
scene, we copy the image into a texture (using the
glCopyTexImage2D() command). During the second pass, this texture is
mapped onto the reflective polygon. The sequence of steps for the
second pass is as follows:

- Position the viewer at the ``real'' eyepoint.
- Draw the non-reflective objects in the scene.
- Bind the texture containing the reflected image.
- Draw the reflective object with the appropriate texture coordinates.
The texture coordinates at the vertices of the reflective object must
be in the same location as the vertices of the reflective object in
the texture. These coordinates may be computed by figuring the
projection of the corners of the object into the viewing plane used to
compute the reflection map (the command gluProject() may
prove helpful). Alternately, the texture matrix can be loaded with
the composite modelview and projection matrices and postmultiplied by
a scale of 1 divided by the size in pixels of the region used to
compute the texture. The texture coordinates would then be the model
coordinates of the vertices.
The texture mapping technique may be more efficient on some systems.
Also, we may be able to use a reflection texture during several frames
(see below).
David Blythe
Thu Jul 17 21:24:28 PDT 1997