Game Development Reference
Since this virtual camera is a reflection, the coordinate system changes from
right-handed to left-handed, and some steps need to be taken in order to account
for this. In OpenGL, it is convenient to call the glFrontFace() function to re-
verse the winding order of front-facing triangles for culling purposes.
In the process of rendering from a virtual camera, it is possible that geometry
lies closer to the camera than the plane representing the reflective surface. This
typically happens when an object straddles the reflection plane and parts on the
opposite side of the plane are flipped backwards in the reflection. If such geome-
try is rendered in the reflection, it can lead to unwanted artifacts in the final im-
age, as shown in Figure 5.20.
The simplest solution to this problem is to enable a user-defined clipping
plane to truncate all geometry at the reflective surface. Unfortunately, even
though most GPUs support generalized user-defined clipping operations, using
them requires that the vertex or fragment programs be modified—a task that may
not be convenient since it necessitates two versions of each program be kept
around to render a particular geometry. Furthermore, the necessary modifications
tend to be slightly different across various GPUs.
Figure 5.20. In this scene, a reflection is rendered about a plane coincident with the water surface.
In the left image, no clipping is performed at the reflection plane, and multiple artifacts appear. At
locations A and B , the portions of the posts that extend below the water surface are seen extending
upwards in the reflection. At location C , some polygons belonging to submerged terrain are visible
in the reflection. As shown in the right image, clipping at the reflection plane removes these
unwanted artifacts. ( Image from the C4 Engine, courtesy of Terathon Software LLC. )
Search Nedrilad ::