Page 14 - Developer
P. 14
and gets rid of the smeared, blurry The core of the fragment egregious artifacts from the
effect on near-to-far edges. shader (using GLSL in this case, previous method, but it still has a
The final issue is to decide but the Cg or HLSL shader would be few issues.
which direction to search along the equivalent) is in Listing 1. The first issue is that we are
scanline—the positive x direction or In this case, we’ve replaced the limited in the amount of negative
the negative x direction? I’ve given P_right end condition with a check parallax we can represent. Recall
away the answer already, but in against zero to avoid an unnecessary that negative parallax occurs when
my initial algorithm I unthinkingly addition, but the same principle objects are closer to the viewpoint
searched in the positive x direction, applies. The constant stereo_ than the convergence plane, and
which had some unexpected effects params contains -/+s, +/-sc, the it shows up visually as objects
In our case we simply repeat the foreground or background information
and hope that the area is small enough that the players don’t notice. Some
ways of reducing the area are to again bring in the convergence plane
(which does reduce the stereo effect, but helps with the errors) or to render
the scene from a camera with a standard frustum, and then reproject twice
to generate the left and right view from that.
on the result. Figure 7a shows the starting offset for the search, and popping out of the screen. For
standard stereo projection, while the search range. GetLinearDepth() aesthetic purposes, we usually
Figure 7b shows the result of this converts the nonlinear depth value don’t want a lot of negative parallax
reprojection algorithm, and the from the texture into a single because if it occurs near the edge
smeared ruin of poor Ratchet’s face. floating-point linear value. of the screen it can destroy the
Tragedy and despair. This shader has the advantage 3D illusion (because one eye can
This is a problem because by in that it works both for reprojecting see the object, while in the other
iterating in the positive x direction the left view to the right one, and it appears chopped off). But it’s
when doing left-to-right reprojection, the right view to the left one, simply difficult to avoid entirely, so ideally
we’re moving in the wrong direction by changing the stereo parameter our algorithm needs to handle it.
along the view ray. Rather than constant. However, if you only While we know that the
searching deeper and deeper into want to reproject from left to right, maximum displacement due to
the screen, we were starting with for example, you can simplify it positive parallax is s, for negative
the maximum depth value for our by removing the “dir” term and parallax there is no practical
ray, and searching more and more adjusting signs accordingly. maximum. Let’s look at Figure 8 to
shallowly. This leads to an early see why this is the case.
exit from the search, and Ratchet’s PROBLEMS WITH Here we see an object with
poor deformed face. Fortunately REPROJECTION negative parallax. The distance
the solution is simple: Reverse the between the left and right view ray
search direction! Figure 7c shows Overall, our approach works intersections is clearly larger than s,
this far better result. quite well and removes the more so we could broaden our search to
include that. However, as objects get
closer and closer to the eye points,
FIGURE 8: Reprojecting a point
with negative parallax. that displacement gets larger and
larger, approaching infinity. Clearly
capturing all negative parallax is not
practical, so the only thing we can do
is set a maximum value, and try to
keep our objects within that amount
of negative parallax. If we end up algorithm it is impossible to
with a situation where objects might perfectly reconstruct such areas,
fall beyond that range, we can bring because the information simply
in the convergence plane to reduce isn’t there (which we can see in
the parallax. Figure 7c, to the right of Ratchet’s
Another set of issues crops face). In our case we simply repeat
up because the new viewpoint the foreground or background
can see parts of objects that the information and hope that the
original can’t. These are known as area is small enough that the
reconstruction issues. The original players don’t notice. Some ways of
problems with Ratchet’s face were reducing the area are to again bring
an extreme example of this, with in the convergence plane (which
some very bad reconstruction. does reduce the stereo effect,
However, even with an improved but helps with the errors) or to
12 GAME DEVELOPER | OCTOBER 2012