Stereo
The OSG has support for stereo out of the box. Currently both anaglyphic
stereo (i.e. red/green or red/cyan glasses) and quad buffered stereo (i.e.
active stereo using shutter glasses, or passive stereo using polarized
projectors & glasses). It is planned to extend this support horizontal
and vertical split window stereo implementations.
Almost all OSG applications have the potential for stereo support simply
by setting the relevant environmental variables, or via command line arguments.
Little or no code changes will be required, the support is handled transparently
inside osgUtil::SceneView's handling of rendering.
If the user is planning to use head tracked stereo, or a cave then it
is currently recommend to set it up via a VR toolkit such as VRjuggler,
in this case refer to the VR toolkits handling of stereo, and do not invoke
the OSG's native support, i.e. keep all the OSG's stereo specific environment
varibles (below) set to OFF, or set the values to off within own your own
applications.
The environmental variables of interest:
OSG_STEREO |
ON |
turn stereo on. |
OSG_STEREO |
OFF |
turn stereo off (default) |
OSG_STEREO_MODE |
ANAGLYPHIC |
use anaglyphic stereo when in stereo (default). |
OSG_STEREO_MODE |
QUAD_BUFFER |
use quad buffered stereo when in stereo. |
OSG_SCREEN_DISTANCE |
0.50 |
set the distance the viewer is from screen in metres (default shown) |
OSG_SCREEN_HEIGHT |
0.26 |
set the height if image on the screen in metres (default shown) |
OSG_EYE_SEPERATION |
0.05 |
set the eye seperation - interoccular distance (default shown.) |
Command line arguments can be used to override these settings:
-stereo |
|
Switch on stereo. |
-stereo |
ON |
Switch on stereo. |
-stereo |
OFF |
Switch off stereo. |
-stereo |
ANAGLYPHIC |
Switch on ANAGLYPHIC stereo. |
-stereo |
QUAD_BUFFER |
Switch on QUAD_BUFFER stereo. |
Examples:
To invoke stereo from the comandline:
sgv -stereo cow.osg
To invoke quad buffered stereo from the commandline:
sgv -stereo QUAD_BUFFER cow.osg
To force all apps to start up in quad buffered stereo (if system supports
it)
export OSG_STEREO=ON
export OSG_STEREO_MODE=QUAD_BUFFER
sgv cow.osg
To set quad buffered stereo to the default, but use the commandline
to switch stereo on:
export OSG_STEREO=OFF
export OSG_STEREO_MODE=QUAD_BUFFER
sgv -stereo cow.osg
Size matters:
For appropriate depth perception the stereo code creates separate left
and eye views, both the frustum and modelview are shifted to account for
the separate eye views. To achieve the right amount of adjustment
the OSG requires the users eye separation, the distance from the eyes to
the screen and the height of the screen. The OSG will use the defaults
of 0.05m,0.5m and 0.26m respectively which are assumed to be reasonable
defaults for most users workstation configurations, note the OSG_SCREEN_HEIGHT
is the image height rather than total size of your monitor/display surface.
For the best stereo effects please measure these values and set them up
via the environmental variables. Once set the views you get should
give improved depth perception. A good way of measuring how well you are
configured for your display is to fly away from objects (using the FlightManipulator
for instance, but not the TrackballManipulator, see below) so that they go of
toward infinity. As they move away the offset between the two images should
tend towards your eye separation, if you achieve this then the object will
be perceived as at infinity.
Camera Manipulator Modes:
There are three osgUtil::CameraManipulator's which come with osgUtil, which
operate as a Trackball, Drive and Flight modes of interaction (see sgv.html for
how to invoke them in the scene graph viewer). The osgUtil::Trackball
Manipulator automatically scales the fusion distance to that which will fusion on
center point of rotation - this will appear at the middle of the monitor at
the monitors depth. Whereas, the osgUtil::DriveManipualtor, osgUtil::FlightManipulator
scale the fusion distance to the distance the viewer is from the screen, the
results in a perception that the virtual world is scaled to physical world, this
is clearly better for simulators and alike. You can control the fusion of
the image in these two modes via the osg::Camera::setFusionDistanceMode(FusionDistanceMode mode)
where mode can be osg::Camera::PROPORTIONAL_TO_LOOK_DISTANCE (used by Trackball) or
osg::Camera::PROPORTIONAL_TO_SCREEN_DISTANCE (used by Drive and Flight),
and osg::Camera::setFusionDistanceRatio(float). See include/osg/Camera for
further details, and the camera manipulators for implementation details. The
fusion distance ratio defaults to 1.0 but can be biased to move objects out or
into screen, they will also appear to get smaller and larger respectively. The
camera manipulators allow the user to alter this value at runtime via the '+'
and '-' keys.