- Background: Depth
Perception & Stereo
In particular, make sure you understand the notions of "parallax" and "homologous points", especially
horizontal and vertical parallax
of homologous points.
Also note that stereo pair generation only makes sense when using perspective projections.
- View Generation for Left and Right Eyes, using separation between eyes = d.
There are at least three approaches, none of which models the actual human vision system exactly:
- Method 1: Two mc_ec matrices: (left eye + common center), (right eye + common center); standard perspective matrix, ec_lds
- Sometimes called "toe-in".
- This is often described as an "incorrect approach" since it introduces vertical parallax
of homologous points (i.e., homologous points that differ in the y as well as in the
x direction.) Users report
eye strain after viewing such displays for a period of time.
- Method 2: Two mc_ec matrices: (left eye + left center),
(right eye + right center); standard perspective matrix, ec_lds
- We require (left eye - left center) == (right eye - right center); i.e., the left and right
eye images have parallel primary lines of sight. Hence the upper left 3x3 submatrices of the
two mc_ec matrices are identical.
- There will be only horizontal – but no vertical – parallax of homologous points
using this method.
- Some authors describe this as the "correct method".
- Method 3: Common mc_ec;
left eye ec_lds derived from projecting points to an eye at (-d/2, 0, 0);
right eye ec_lds derived from projecting points to an eye at (d/2, 0, 0)
As with the previous method:
- There will be only horizontal – but no vertical – parallax of homologous points
using this method.
- Some authors describe this as the "correct method".
Visual parallax comparisons:
- Method 1 will always exhibit vertical parallax; methods 2 and 3 will never exhibit vertical parallax.
- Method 2 will always exhibit negative horizontal parallax; methods 1 and 3
can exhibit either positive or negative horizontal parallax, depending on how points
relate to the view parameters. In a typical scene rendered using either method 1 or method 3,
some points will exhibit positive parallax, and others negative parallax.
- Study this visual comparison.
Matrix comparisons: Let us define M = ec_lds * mc_ec, and then let Mleft and
Mright be the resulting left eye and right eye matrices. Then:
- In method 1, all 16 elements of Mleft differ from those of
Mright. This is the algebraic reason why we get vertical parallax. (It is
also easy to understand geometrically why we get vertical parallax since there are two
different projection planes intersecting in a vertical line parallel to the EC y-axis.)
- In method 2, only the element in the fourth column of the first row in Mleft and
Mright differ. Thus, only the LDS x coordinates of homologous
points will differ.
- In method 3, the entire first row of Mleft differs from that in
Mright. The other three rows of the two matrices are identical, however,
hence it is still the case that
only the LDS x coordinates of homologous points will differ.
- General Guidelines
There have been many published guidelines on how the stereo parameters should be set as well as
strategies for optimal placement of the objects in a scene inside the view frustum. For example:
- The eye separation should be approximately 1/20 of the distance from
the eye to the projection plane. In terms of our viewing parameter naming conventions, this guideline
suggests that we set the
separation, d, to be -ecZpp/20.
- No part of the scene should lie in the portion of the
view frustum closer than 1/2 of the distance
from the projection plane to the eye.
- Avoid having portions of the scene in the parts of the left eye frustum
that are not also in the right eye frustum, and vice versa.
- Device-Specific Guidelines
It is not unusual for specific stereo-capable viewing systems to have unique optimal viewing conditions.
- Mechdyne's suggestions for viewing in their "mini-CAVE" state that
the best viewing experience is obtained if you are standing (not sitting) roughly six feet in front of
the screen. In their environment, you will observe separation of left and right images as you either
lower your eyes (e.g., as you sit down) or as you move closer to the screen.
- OpenGL APIs and Structures
- You must create a Rendering Context that supports stereo. In GLFW, you
do: glfwWindowHint(GLFW_STEREO, GL_TRUE) before the glfwCreateWindow call.
(The glfwCreateWindow call will fail if you are not running on a platform that actually supports
stereo view generation.)
- In addition to the GL_BACK (and GL_FRONT) buffers used
in double buffering, there are GL_BACK_LEFT and GL_BACK_RIGHT buffers
(and the corresponding
"front" ones). You then draw the scene twice, once for each eye. Use glDrawBuffer
to tell OpenGL which buffer you are targeting when rendering the scene. After drawing the
scene for each eye, calling glfwSwapBuffers swaps both the left and right buffers
simultaneously.