Page 10 - Developer
P. 10

WHY WE COULDN’T          view space or in NDC (Normalized   in the bottom row), and each   you still need to pass data through
          USE STANDARD             Device Coordinates) space.   term has equal magnitudes but   the GPU twice, which takes time.
          STEREOGRAPHIC              When projecting for stereo, we   opposite signs for each view. The   In our case, we were already up
          PROJECTION               add two additional transformations   left view will have negative shear   against the 30 fps boundary, so we
                                   to represent the interaxial and   and positive translation, while the   had very little extra rendering time.
             Before looking at our stereo   convergence: an xz-shear S   right view has positive shear and
          reprojection solution, let’s   and an x-translation T. Some   negative translation.
          quickly review how the standard   implementations incorporate the   So what do we choose for the   OUR SOLUTION:
          stereographic method works. The   translation into the view matrix   magnitude of S and T? They need to   STEREO REPROJECTION
          idea is that we are trying to provide   and the shear into the projection   be related; otherwise you will end up

          to each eye (via shutter glasses,   matrix, but I find it more compact   with bad convergence and headaches     The alternative to rendering
          or polarization, anaglyph color, or   to add both to the projection   for your viewers. Other things that   everything twice is to render color
          head-mounted display) a view from   matrix. The end result can be seen   need to be taken into consideration   and depth information for a single
          that particular eye’s perspective.   in Figure 2, showing both standard   are your monitor/television size and   view, then use the information
            There are two pieces here: First,   D3D and OpenGL perspective   your horizontal field of view. A larger   for that view to generate a stereo

          each eye is displaced from the   projection matrices.  monitor implies that you will be   pair—rendering the left view and
          center by a certain distance, called              sitting farther from it, which implies   using it to create the right view,
          the interocular distance. It’s this               that less shear is required. And the   for example. Because the original
          displacement that allows stereo                   convergence distance in turn is   image will not have the correct

          viewing in the first place. Secondly,              dependent on the field of view.   projection for at least one of the

          depending on what we’re focusing                    The set of equations that we   views, we will have to remap the
          on, the eyes will toe in or out when              used in ALL 4 ONE can be found in   color data to match the new view,
          we look at a near or far object,                  Figure 3, partially derived from   or perform reprojection. For the
          respectively (see Figure 1).                      Samuel Gateau’s GDC 2009 talk on   sake of the rest of the article
            The interocular distance is about               stereoscopic 3D [see Reference   we’ll assume that unless stated
          5–8cm, measured from the center                   1] and the Sony documentation. As   otherwise, we’ll be reprojecting
          of each pupil. When working with                  we can see, S is dependent on the   from a left view to a right one.
          virtual cameras, we often refer to the            interocular distance and monitor   We will need to have access
          interaxial distance instead. Because              width, and T is dependent on S,   to the color and depth images to

          of toe-in, there will be a plane where            convergence distance, and field of   do this. If you’re rendering into a
          points on that plane will project to              view. This is a bit counterintuitive,   backbuffer (or don’t have access to
          the same screen position in both                  but it works quite well.  a console that lets you just dip into
          views. We call this the convergence                                        memory and point a new texture
          plane, and the distance to that                                            to it), you’ll need to change your
          plane is known as the convergence                                          rendering approach. Fortunately,
          distance. Points between the view                                          if you’re using something like
          points and the convergence plane   FIGURE 2: Standard stereoscopic         deferred rendering or deferred
                                   projection matrices.
          will have negative parallax (and will                                      lighting, you’ll have already done
          appear to stick out of the screen),                                        this and will have textures available
          and points behind the convergence   Note that the shear and translation    with this information. Otherwise,
          plane will have positive parallax.   have opposite signs (they end up      you’ll have to use render targets in
          Note that the units for these   with the same sign in the OpenGL           Direct3D or framebuffer objects in
          distances could change, depending   projection matrix because the   FIGURE 3: Stereoscopic parameters.  OpenGL for both color and depth.
          on whether you are measuring in   shear gets multiplied by the —1            While CRYSIS 2 was the fi rst
                                                            The process at this point is quite   notable use of stereo reprojection in
                                                            simple: Render two views, one for   games, it is not a new technology.
                                                            each eye, and send each image to   Erik Benerdal described a similar
                                                            the display. Other than setting up   approach on his blog in 2008 [see
                                                            the projection matrix, this doesn’t   Reference 2]. Other reprojection
                                                            take much work, and in fact some   approaches have used scatter-
                                                            stereo drivers take advantage of   based splatting or image warping
                                                            this simplicity to automatically   using meshes [see Reference
                                                            provide stereo for games. However,   3]. The technique I’m presenting
                                                            it does have one disadvantage: You   here is a gather approach derived
                                                            do have to render the scene twice.   from parallax occlusion mapping,
                                                            We could optimize this a bit, of   which takes a color image, a depth
                                                            course; we could do all nonrendered   image, and uses raycasting to

                                                            processing first, cull for the convex   create the appearance of geometry
                                                            hull of both frustums rather than   displacement within a shader.
                                                            one at a time, or generate a single   A full description of parallax
          FIGURE 1:
          Stereoscopic 3D                                   pushbuffer and only modify the   mapping is outside the purview

          frustum setup.                                    projection matrices—but in the end   of this article. You can find more
           8  GAME DEVELOPER   |  OCTOBER 2012
   5   6   7   8   9   10   11   12   13   14   15