This page has been translated automatically.
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Setting Up Development Environment
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
Double Precision Coordinates
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Stereo Rendering

Unigine supports "easy on the eye" stereo 3D rendering out-of-the box for all supported video cards. Unigine-powered 3D stereoscopic visualization provides the truly immersive experience even at the large field of view or across three monitors. It is a completely native solution for both DirectX and OpenGL APIs and does not require installing any special drivers. Depending on the set stereo mode, the only hardware requirements are the equipment necessary for stereoscopic viewing (for example, active shutter glasses, passive polarized or anaglyph ones) or a dedicated output device.

You may notice a drop in performance when using stereo rendering. This happens because all viewports are effectively rendered twice each frame.

Stereo Modes#

There are several modes of stereo rendering available for Unigine-powered application. To enable them, no special steps or modifications are required. Just use a ready-compiled plugin library, set the desired start-up option and you application is stereo-ready!

Stereo libraries are located in the lib/ folder of the UNIGINE SDK.

Separate Images#

This mode serves to output two separate images for each of the eye. It can be used with any VR/AR output devices that support separate images output, e.g. for 3D video glasses or helmets (HMD). See further details on rendering below.

To launch Separate images stereo mode, load the AppSeparate plugin.

Separate images stereo mode

Separate images stereo mode

Quad Buffered Stereo#

This mode uses the best of the native hardware support of 3D stereo in NVIDIA Quadro video cards which are capable of quad buffering. Unigine utilizes it to gain a good performance. However, other NVIDIA cards also support this mode and show no lower level of performance.

To enable the Quad Buffered Stereo mode, follow the instructions.

Oculus Rift#

This mode is used to support the Oculus Rift head-mounted display (the HD mode is also available).

To launch Oculus Rift mode, load the AppOculus plugin.

Anaglyph Mode#

Anaglyph stereo is viewed with red-cyan anaglyph glasses. See further details on rendering below.

To launch Anaglyph stereo mode:

  1. Specify the STEREO_ANAGLYPH definition on the start-up (together with other required CLI arguments).
  2. Run the 32-bit or 64-bit application (or its debugging version).
Shell commands
main_x86 -extern_define STEREO_ANAGLYPH
Anaglyph stereo mode
Anaglyph stereo mode

Interlaced Lines#

Interlaced stereo mode is used with interlaced stereo monitors and polarized 3D glasses. See further details on rendering below.

In this mode, the vertical resolution of the image is dropped in half.

To launch the interlaced lines stereo mode:

  1. Specify the STEREO_INTERLACED definition on the start-up (together with other required CLI arguments).
  2. Run the 32-bit or 64-bit application (or its debugging version).
Shell commands
main_x86 -extern_define STEREO_INTERLACED
Interlaced lines stereo mode
Interlaced lines stereo mode

Mobile Stereo#

Horizontal and Vertical stereo modes are supported for glass-free MasterImage 3D displays on mobile devices. The same mode (a horizontal or a vertical one) is selected in the graphics chip driver settings. See further details on rendering below.

To launch Horizontal stereo mode:

  1. Specify the STEREO_HORIZONTAL definition on the start-up (together with other required CLI arguments).
  2. Run the 32-bit or 64-bit application (or its debugging version).
Shell commands
main_x86 -extern_define STEREO_HORIZONTAL
Horizontal stereo mode for mobile devices
Horizontal stereo mode for mobile devices

To launch Vertical stereo mode:

  1. Specify the STEREO_VERTICAL definition on the start-up (together with other required CLI arguments).
  2. Run the 32-bit or 64-bit application (or its debugging version).
Shell commands
main_x86 -extern_define STEREO_VERTICAL
Vertical stereo mode for mobile devices
Vertical stereo mode for mobile devices

Stereo Rendering Model#

The stereo rendering model uses asymmetric frustum parallel axis projection (called off-axis) to create optimal stereo pairs without vertical parallax (vertical shift towards the corners).
It means, two cameras with parallel lines of sight are created, one for each eye. They are separated horizontally relative the central position (this distance is called the eye separation distance and can be adjusted to avoid eyestrain from stereoscopic viewing). Both cameras use asymmetric frustum, when the far plane is parallel to the near plane, yet they are not symmetrical about the view axis. It enables to correctly align projection planes of two cameras to the zero parallax plane (i.e. the screen). Asymmetric frustum parallel axis projection produces no distortions in the corners making the stereoscopic image completely comfortable to the eye.

When rendered, objects that get in front of the camera's focal distance (that is, its projection plane) are perceived as popping out of the screen; objects that are behind it appear to be behind the screen and convey the impression of scene depth.

Unigine Stereo Rendering Pipeline#

Unigine engine calculates the images for both eyes using the appropriate postprocess shader. Which shader is applied depends on the chosen stereo mode.

  • Anaglyph mode uses the post_stereo_anaglyph postprocess material and only one render target. Two images are filtered by red and blue channels, superimposed and output onto the screen to be viewed through colored glasses.
  • Separate images mode uses the post_stereo_separate postprocess material. It creates two render targets and outputs left and right eye images that are offset relative to each other onto the two separate monitors.
  • Oculus Rift mode uses the post_stereo_separate postprocess material. Images for the left and right eyes are output onto the corresponding half of the screen and lenses of the Oculus Rift display distort them to make the eyes perceive this images the same way as in the real world.
  • In case of Quad Buffer mode, the post_stereo_separate postprocess material is used.
  • Interlaced lines mode uses the post_stereo_interlaced postprocess material. This mode is based on the interlaced coding. For example, the image for the left eye can be displayed on the odd rows of pixels with one polarization and the image for the right eye - on the even rows with other polarization.
  • Horizontal and Vertical stereo modes use only one render target. After that, the graphics chip driver handles it as two images aligned horizontally or vertically (depending on the set mode) and stretches them onto the screen to create a stereo effect. If the horizontal stereo mode is used, the post_stereo_horizontal postprocess material is applied. In case of the vertical stereo mode, the post_stereo_vertical postprocess material is used.

If stereo rendering is disabled (for example, when 3D Vision application is switched to the windowed mode), post_stereo_replicate material is used and the postprocess shader creates a simple mono image (the same for all viewports, if there are many). This material allows to switch to normal rendering and avoid the black screen when the engine is not rendering stereo pairs.

Stereo rendering is optimized to be performance friendly while not compromising the visual quality. For example, shadow maps are only rendered once and used for both eyes; geometry culling is also performed only once. Most of the rendering passes are still doubled, that is why it might make sense to turn off unnecessary passes or set a global shader quality to lower level to minimise the performance drop.

Viewing Settings#

Settings that allow adjusting stereo for comfortable viewing are found on the additional Stereo tab in the main menu. They are available for all stereo modes.

Distance Distance to the screen. This is a distance in world space to the zero parallax plane, i.e. to the point where two views line up.
The higher the value, the further from the viewer the rendered scene is and the lesser stereo effect is.
Radius Half of the eye separation distance. The eye separation distance is the distance of interaxial separation between the cameras used to create stereo pairs.
The higher the value, the stronger stereo effect is.
Offset An offset after perspective projection.

Customizing Stereo#

Stereo rendering can be controlled via the following code:

  • Stereo script stereo.h (located in data/core/scripts/system folder). By default it is included in the system script unigine.cpp. You can modify the stereo.h script in order to change the default camera configuration.
  • If you choose not to include the stereo script into the system one, you can set the appropriate stereo mode definition and control stereo parameters directly via engine.render.setStereoRadius() and engine.render.setStereoDistance() functions. In this case, you need to implement your own camera configuration in therender() function of the system script:
    Source code (UnigineScript)
    int render() {
    	#ifdef STEREO_MODE
    		// implementation of a custom camera configuration
    	return 1;
The STEREO_MODE definition should be specified on the application start-up as the argument of the -extern_define command-line option.

Native Stereo Reprojection#

Stereo Reprojection mode for VR enables to render 45 FPS as 90 FPS. Instead of rendering a picture for both eyes each frame, it is rendered for one of them, while the picture for the other is obtained by making reprojection of the rendered one, next time the picture is rendered for the second eye and reprojected for the first one, and so on. Two modes are available:

  • dynamic reprojection - slower, but more accurate, more pronounced ghost effect
  • fast reprojection - faster, reduced ghost effect, but clipping of frontal parts of moving objects may occur

Reprojection does not give an x2 performance gain as there are a lot of other things to be rendered in addition to the ones rendered per-eye (such as shadow maps etc.). Moreover, in case of a CPU bottleneck, reprojection won't give any gain at all.

It is recommended to enable stereo reprojection in the following cases:

  • you have a stable 70-80 fps and just need some extra boost to get to 90
  • you have a fluctuating fps (like 90, then 45, and 90 again), in this case reprojection will help you to get stable 90

In case if your initial fps is below 45, reprojection will half the framerate, and you'll end up having a completely messed up image. In this case reprojection should be disabled.

To set the value via the console, use the render_stereo_reprojection console command.

Hidden Area#

Some pixels are not visible in VR. You can optimize rendering performance by skipping them. The following culling modes are available for such pixels:

  • OpenVR-based culling mode - culling is performed using meshes returned by OpenVR. Take note, that culling result depends on HMD used.
  • Custom culling mode - culling is performed using an oval or circular mesh determined by custom adjustable parameters.

You can specify a custom mesh representing such hidden area, adjust its transformation and assign it to a viewport.

To set the value via the console, use the render_stereo_hidden_area console command.

Articles in This Section

Last update: 2019-08-16
Build: ()