Page 16 - Developer
P. 16

references
                                 i
                                 t
                               e
                                c
                                  o
                                      rix an
                                         d p
                                      t
                                  n m
                                     a
                        e s
                          t
                       l
                      t
                       y
                          e
                              o
                               j
                              r
                           re
                            o p
                                           r
                                                         h
                                                          e l
                                                                   s u
                                                       t
                                                       o t
                                                              e
                                                               w giv
                                                            ft vi
                                                                  e
                                                           e
                                                                     s
                                              c
                                              t
                                             e
                                            o
                                             j
                                                    in
                                                     t in
                                                   o
                                               in
                                                g a p
            Using the D3D-style stereo projection matrix and projecting a point into the left view gives us:  :
                 e D3D-
            U
                h
                     s
             sin
               g t
                                                                                      [1]   Gateau, Samuel. “The In and
                                                                                        Out: Making Games Play
                                                                                        Right with Stereoscopic 3D
                                                                                        Technologies.” GDC 2009, http://
                                                                                        developer.download.nvidia.com/
                                                                                        presentations/2009/GDC/GDC09-
                                                                                        3DVision-The_In_and_Out.pdf
                                                                                      [2]   Benerdal, Erik. “Generating
                                                                                        stereoscopic images with parallax
                                                                                        occlusion mapping,” www.scalari.
                                                                                        net/2008/04/22/generating-
                                                                                        stereoscopic-images-with-
                                                                                        parallax-occlusion-mapping
            Aft e r t h e re c ip r oc al divi d e an d c o n si d e rin g o nl y t h e   Subtracting these gives the displacement between   [3]   Didyk, Peter, Tobias Ritschel, Elmar
            After the reciprocal divide and considering only the
                                               Subtracting these gives the displacement between
            x x x values, we end up with: :    the left and right views in NDC space:   Eisemann, Karol Myszkowski,
            x values, we end up with:
                                               the left and right views in NDC space:
                      d u
              valu
                   e e
                           h
                 , w
                 s
                        p wi
                     n
                e
                          t
                                                                                        and Hans-Peter Seidel. “Adaptive
                                                                                        Image-space Stereo View
                                                                                        Synthesis.” In Vision, Modeling,
                                                                                        and Visualization (2010), Reinhard
                                                                                        Koch, Andreas Kolb, Christof Rezk-
                                                                                        Salama (Eds.)
                                                                                      [4]   Brawley, Z., and Tatarchuk, N.
                                                                                        2004. “Parallax Occlusion Mapping:
                                               However, NDC space has a range from -1 to 1.
                                               However, NDC space has a range from -1 to 1.   Self-Shadowing, Perspective-
                                               To convert this to a displacement for texture
                                               To convert this to a displacement for texture   Correct Bump Mapping Using
                                               coordinates, which range from 0 to 1, we halve the
                                               coordinates, which range from 0 to 1, we halve the   Reverse Height Map Tracing.” In
                 x
                 x
                            ul
                                o
                     r is t
                              f n
                                  -
                                               distance, which gives us:
                                  s
                           s
                         e re
                    t
                                 n
                   n
                    e
                        h
                  e
                 _c
                                            n
            Where x_center is the result of non-stereo projection.  .   distance, which gives us:   ShaderX3: Advanced Rendering
            Where x_center is the result of non-stereo projection.
                                           i
                                          t
                             t o
                                           o
                                         c
                                    re
                                     o p
                                   t
                                   e
                                        j
                                         e
                                       r
                                        o
                                                                                        with DirectX and OpenGL, Engel,
            Expanding and simplifying, we end up with:                                  W., Ed., Charles River Media, pp.
            Expanding and simplifying, we end up with:
                                                                                        135-154.
                                                                                      [5]   van de Hoef, Marries, and Bas
                                                                                        Zalmstra. “Fast Gather-based
                                                                                        Construction of Stereoscopic
                                                                                        Images Using Reprojection.”
                                                                                        Utrecht University, 2011.
                                                        S
                                                                   arl
                                                                    y t
                                                                  e
                                                          i
                                                         w
                                                                         am
                                                      e
                                                     a
                                                                       e s
                                                                      h
                                                    p
                                                      c
                                                     l
                                                                           e a
                                                                               e
                                                            , t
                                                f w
                                                                              h
                                                                  l
                                               If we replace S with s, this is clearly the same as the
                                               If we replace S with s, this is clearly the same as the
                                                             his is c
                                               I
                                                                            s t
                                                  e re
                                                          th
                                                                     wh
                                               equation in Figure 6, so s is just S when reprojecting
                                                                           o
                                               equation in Figure 6, so s is just S when reprojecting
                                                                          p
                                                                          r
                                                                            j
                                                                             t
                                                                              in
                                                                       n re
                                                                             c
                                                                      e
                                                                            e
                                                                               g
                                               from a left eye view to a right eye view. Note that for
                                               from a left eye view to a right eye view. Note that for
                                               center reprojection, we would split the difference
                                               center reprojection, we would split the difference
                                               going from center to left and center to right, and so
                                               going from center to left and center to right, and so
                                               halve the displacement.
                                               halve the displacement.
                                                                       o
                                                                t
                                                                 an
                                                                     r c
                                                               o
                                                                r
                                                                  t fo
                                                                              his
                                                                            g t
                                                                           in
                                                                       m
                                                                         p
                                                                         ut
                                                     , si
                                                   ain
                                                         s are im
                                                       gn
                                                  Again, signs are important for computing this:
                                                  Again, signs are important for computing this:  :
                                                   g
                                                  A
                                                              p
                                       x
                                       x
                                               for reprojecting and rendering the left eye, we’d use
            (Recall that d is cot(fov/2)). Similarly, for x_right:
            (Recall that d is cot(fov/2)). Similarly, for x_right: t :  fo r re p r o j e c t in g an d re n d e rin g t h e l e ft e y e , w e ’ d u s e
                                       _ri
                                        gh
                                               for reprojecting and rendering the left eye, we’d use
                                                                             t t
                                                                h
                                                                         e in
                                                                               e
                                                                              h
                                                                       , w
                                                                            e
                                                               r t
                                                                           v
                                               –s, +sc/z, –S, and +T. For the right eye, we invert the
                                                                            r
                                               –s, +sc/z, –S, and +T. For the right eye, we invert the
                                                                      y
                                                                   gh
                                                                    t e
                                                                 e ri
                                                              o
                                                            . F
                                                                      e
                                               signs and so use +s, –sc/z, +S, and -T.
                                               signs and so use +s, –sc/z, +S, and -T.
                                                        s
                                                                              h
                                                                               e
                                                               t
                                                              ui
                                                         ul
                                                                             f t
                                                                  e
                                                          t is q
                                                               e ni
                                                                     e g
                                                      d re
                                                  h
                                                                  c
                                                                       et m
                                                     n
                                                   e e
                                                                   . W
                                                  T
                                                  The end result is quite nice. We get most of the
                                                                           t o
                                                                          o
                                                                          s
                                                  The end result is quite nice. We get most of the
                                               speed benefits of reprojection, with the good-looking
                                               speed benefi
                                                    e
                                                     n
                                                  e
                                                  d b
                                                        ts of reprojection, with the good-looking  ts of reprojection, with the good-looking

                                                      e
                                                       fi
                                               s
                                                p
                                                 e
                                               alpha of standard stereo, and all it took was a little bit
                                               alpha of standard stereo, and all it took was a little bit
                                               alp h a o f s t an d ar d s t e re o , an d all i t t o o k wa s a li t tl e b i t
                                               of math and some extra setup.
                                               of math and some extra setup.
          that the alpha-blended objects will   primarily dependent on our   DIY 3D  code.php. I’m looking forward to
          have the correct depth occlusion.   convergence plane distance c           seeing how you improve upon it in
          Secondly, we must compute   and our interocular distance i. In     That’s the whirlwind tour   your future games!
          standard stereo projection matrices   reprojection we have the same   of our implementation of 3D
          that will match up with our   convergence plane distance, but   stereoscopy in RATCHET & CLANK:   JIM VAN VERTH has beenworked in the
          reprojected result.      we have a different value s that   ALL 4 ONE. I hope this gives you   games industry since 1996, and is
                                   probably bears some relation to   some direction in writing your   currently a senior engine programmer at
          MATCHING STANDARD        the interocular distance. However,   own version of 3D stereoscopic   Insomniac Games. He’s also co-author of
          AND REPROJECTION         it’s unclear what that would be   reprojection, no matter the   the book Essential Mathematics for Games
          STEREO                   to match the standard stereo   platform. To give you a starting   and Interactive Applications. You can email
                                   projection. To determine that, let’s   point, I’ve created an OpenGL   him at jim@essentialmath.com.
             Remember that we have   project a point into left and right   demo demonstrating the basic
          two variables for our standard   NDC space and measure the delta   techniques, which you can find   RATCHET  AND  CLANK images courtesy/
          stereo: S and T, which are   between them in the x direction.   at http://gdmag.com/resources/  copyright SCEA 2012
          14  GAME DEVELOPER   |   OCTOBER 2012
   11   12   13   14   15   16   17   18   19   20   21