151
10
PracticalStereoRendering
Matthew Johnson
Advanced Micro Devices, Inc.
This chapter discusses practical stereo rendering techniques for modern game
engines. New graphics cards by AMD and Nvidia enable application developers
to utilize stereoscopic technology in their game engines. Stereo features are ena-
bled by middleware, driver extensions, or the 3D API itself. In addition, new
consumer-grade stereoscopic displays are coming to the market, fueled by the
excitement over 3D movies such as Avatar and How to Train Your Dragon.
10.1IntroductiontoStereo3D
In the real world, people use a variety of methods to perceive depth, including
object size, shadows, object occlusion, and other cues. Additionally, having two
eyes allows a person to perceive depth by generating a pair of images that are
subsequently merged into one image by the human brain. This is called binocular
vision.
The eyes have several mechanisms to focus and merge a stereoscopic pair
into one image:
Binocular disparity. The horizontal displacement between the eyes (called
the interaxial or interpupillary distance) introduces a shift between the imag-
es viewed by the eyes. This can be observed, for example, by focusing on an
object and alternately closing the left and right eye—the focused object is
shifted left and right.
Convergence. Convergence arises through the ability to rotate the eyes in-
ward to help focus on an object in an effort to merge the stereo pair. This of-
ten causes discomfort for the person, especially if the object is very close.
The opposite of this is divergence, but human eyes are only capable of slight-
ly diverging.
152 10.PracticalStereoRendering
Accommodation. Accommodation is the ability of the eye to focus on an ob-
ject by changing the curvature of the lens. Accommodation is often simulated
today even without stereo. For example, game engines that utilize depth-of-
field algorithms often apply a postprocess blur to objects that are deemed out
of focus.
The stereo algorithm described in this article takes advantage of binocular dispar-
ity to achieve the desired stereo effect.
10.2OverviewofStereoDisplays
There are several types of new stereo displays coming to the market. In the past,
these monitors and projectors typically used proprietary display formats to en-
code stereoscopic data, requiring special software and hardware to drive them.
Newer standards, such as Display Port 1.2 and HDMI 1.4, define several required
stereo formats that must be supported by qualifying hardware. The availability of
common specifications simplifies the implementation of stereo for middleware
and application vendors.
The principle challenge in stereo displays is ensuring that the correct image
is transmitted to the correct eye. Anaglyph glasses are a relatively low-cost solu-
tion to this problem. These glasses are designed to filter certain colors so that
each eye can receive only one set of colors. If any of those colors “bleed” into the
other eye, a ghosting artifact can occur. In addition, it is difficult to get a full
range of colors across the spectrum. Despite this fact, anaglyph glasses are con-
stantly improving with certain technologies or color combinations that diminish
these shortcomings.
Because of the disadvantages of anaglyph glasses, newer stereo displays are
often bundled with liquid crystal shutter glasses. These glasses work by alternat-
ing between one eye and the other (by applying a voltage to one of the lenses to
darken it) at a fast refresh rate. Shutter glasses have the advantage of supporting
the full color range.
The main disadvantage with shuttering is the flickering that is often observed
at lower refresh rates. This is becoming less of an issue as higher refresh rate dis-
plays become available. For an HDMI 1.4-compliant stereo display, the high-
definition mode
1
280 720 (720p) is supported up to 120 Hz (or 60 Hz per eye),
while the
1
920 108
0
mode (1080p) is supported at 48 Hz (24 Hz per eye). A
24-Hz refresh rate is considered the baseline in television and interactive
media.

Get Game Engine Gems 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.