/ Stereo settings



Stereo settings

The OSG has support for anaglyphic stereo (i.e. red/green or red/cyan glasses), quad buffered stereo (i.e. active stereo using shutter glasses, or passive stereo using polarized projectors & glasses) and 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. It is a simple as:

osgviewer --stereo cow.osg

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 keep all the OSG's stereo specific environment variables (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
  OFF Turn stereo off (default).
OSG_STEREO_MODE ANAGLYPHIC Use anaglyphic stereo when in stereo (default).
  QUAD_BUFFER Use quad buffered stereo when in stereo.
  HORIZONTAL_SPLIT Use horizontal split stereo mode when in stereo
  VERTICAL_SPLIT Use vertical split stereo mode 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 of image on the screen in metres (default shown)
OSG_SCREEN_WIDTH 0.325 Set the width of image on the screen in metres (default shown)
OSG_EYE_SEPARATION 0.06 Set the eye separation - interoccular distance (default shown.)
OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION 42 Set the number of pixels between the left and right viewports (default shown).
OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING LEFT_EYE_LEFT_VIEWPORT Set the left eye to render to left viewport, right eye to right viewport (default).
  LEFT_EYE_RIGHT_VIEWPORT Set the left eye to render to right viewport, right eye to left viewport.
OSG_SPLIT_STEREO_VERTICAL_SEPARATION 42 Set the number of pixels between the top and bottom viewports (default shown).
OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING LEFT_EYE_TOP_VIEWPORT Set the left eye to render to top viewport, right eye to bottom viewport (default).
  LEFT_EYE_BOTTOM_VIEWPORT Set the left eye to render to bottom viewport, right eye to top viewport.

Command line arguments can be used to override these settings:

--stereo   Switch on stereo.
--stereo ON Switch on stereo.
  OFF Switch off stereo.
  QUAD_BUFFER Switch on QUAD_BUFFER stereo.


To invoke stereo from the comandline:

osgviewer --stereo cow.osg

To invoke quad buffered stereo from the commandline:

osgviewer -stereo QUAD_BUFFER cow.osg

To force all apps to start up in quad buffered stereo (if system supports it)

osgviewer cow.osg

To set quad buffered stereo to the default, but use the commandline to switch stereo on:

osgviewer -stereo cow.osg

Size matters:

For appropriate depth perception the stereo code creates separate left and right 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.