172 11.Making3DStereoscopicGames
setLeftEyeProjection();
setLeftEyeViewport();
Drawcall();
Listing 11.1. This code demonstrates how the images for the left and right eyes can be combined
in a single render target by moving the viewport.
11.7SceneTraversal
To improve the scene traversal for both cameras, it is possible to take into ac-
count the similarities between both views. This can be used to improve the scene
management at a lower granularity. In fact, if we assume that a point in the rela-
tive right-eye viewing position is
right
,,
yz
P
, then the observation that the
corresponding point for the relative left-eye viewing position is
left
,,
eyzP ,
where e is the camera separation, allows us to improve the scene traversal, where
a normal vector
N to a polygon in one eye is also valid for the other eye. This
could lead to improved hidden surface removal and could also help us discard
objects for both eyes using conservative occluders for occlusion queries. This
helps minimize the CPU and GPU workload. On the PlayStation 3 platform, a
common approach is to perform backface culling using SPU programs. There-
fore, it is possible to perform backface culling for both views in a single pass.
This function consists of performing a dot product and testing the result. If we
compute the view separately, this involves the following operations:
23 3 1
662.
multiplication addition comparison
multiplication addition comparison
This can be improved, and we need to consider the following cases:
■ Polygon is front-facing for both views.
■ Polygon is back-facing for both views.
■ Polygon is front-facing for one view and back-facing for the other view.
Let
N be the normal of a triangle, let
,,
LL
yz
be the direction from one of
the triangle’s vertices to the left camera position, and let
,,
R
yz
be the
direction from the same vertex to the right camera position. The triangle is front-
facing for the left camera if
L
V
, and it is front-facing for the right camera
if
0
V
. Using
LR
x
, we need