This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
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
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine.VR Class

The base class for managing virtual reality in UNIGINE.

VR Initialization
#

By default, VR is not initialized. To run the engine with VR, you need to specify the -vr_app command-line option on the application start-up.

Notice
You cannot launch the deprecated VR plugins (OpenVR, Varjo, Oculus) when the built-in VR is initialized, as it overrides the plugin's functionality. If you try to add a VR plugin after VR initialization, you will get an error message.

Supported Graphics APIs
#

The following graphics APIs are supported out of the box:

  • DirectX 11
  • DirectX 12
  • Vulkan
Notice
For OpenGL API support, use the corresponding VR plugins (deprecated).

VR Class

Enums

API#

NameDescription
NULL = 0VR API is not initialized.
VARJO = 1Varjo API.
OPENVR = 2OpenVR API.

VIEWPORT_TYPE#

NameDescription
CONTEXT = 0Context (low-res) viewport.
FOCUS = 1Focus (high-res) viewport.
NUM = 2Number of viewport types.

EYE_TYPE#

NameDescription
LEFT = 0Left eye.
RIGHT = 1Right eye.
NUM = 2Number of eye types.

MIRROR_MODE#

NameDescription
BEGIN = 0The first element to be used for iteration.
BLACK_SCREEN = 0No image (black screen).
MONO_LEFT = 1Mono image for the left eye.
MONO_RIGHT = 2Mono image for the right eye.
STEREO = 3Stereo image (left and right eyes).
END = 3The last element to be used for iteration.

WINDOW_MODE#

NameDescription
BEGIN = 0The first element to be used for iteration.
DISABLED = 0Showing the mirrored image is disabled.
MAIN = 1The main window shows the mirrored image.
END = 1The last element to be used for iteration.

TRACKING_SPACE#

NameDescription
BEGIN = 0The first element to be used for iteration.
UNKNOWN = 0Poses are provided in the coordinate system defined by the tracker driver.
SEATED = 1Poses are provided relative to the seated zero pose.
STANDING = 2Poses are provided relative to the safe bounds specified by the user.
END = 2The last element to be used for iteration.

Properties

bool RenderEnabled#

Console: vr_render_enabled
The value indicating if rendering into the head-mounted display is enabled.
The default value is false.

bool PeripheralRenderingModeEnabled#

Console: vr_peripheral_rendering_mode_enabled
The value indicating if the peripheral rendering mode is enabled. In this mode, the HMD has two context (peripheral) and two focus displays. You can disable two additional viewports to improve peformance.
Notice
This feature is available for the Varjo devices only.
The default value is false.

int MirrorMode#

Console: vr_mirror_mode
The mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window.
One of the following values:
  • 0 - black screen (no image is displayed).
  • 1 - image rendered for the left eye.
  • 2 - image rendered for the right eye.
  • 3 - stereo image (both the left and right eyes). (by default)

int WindowMode#

Console: vr_window_mode
The window mode that defines which window will display the mirrored image (i.e. VR image).
One of the following values:
  • 0 - mirroring is disabled.
  • 1 - main window displays the mirrored image. (by default)

VR::TRACKING_SPACE TrackingSpace#

Console: vr_tracking_space
The zero pose of the tracking origin.
One of the following values:
  • 0 - seated.
  • 1 - standing. (by default)
  • 2 - raw (uncalibrated).

bool MotionPrediction#

Console: vr_motion_prediction
The value indicating if motion prediction in the Varjo headsets is enabled. When enabled, the engine submits the velocity value from the GBuffer to the Varjo Composer.
The default value is false.

float MotionPredictionVelocityPrecision#

Console: vr_motion_prediction_velocity_precision
The factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
Notice
This feature is available for the Varjo devices only.

Range of values: [eps, inf]. The default value is : 32.0f.

float MotionPredictionVelocityTimeDelta#

Console: vr_motion_prediction_velocity_time_delta
The factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
Notice
This feature is available for the Varjo devices only.

Range of values: [eps, inf]. The default value is : 1.0f / 60.0f.

bool FoveatedRenderingEnabled#

Console: vr_foveated_rendering_enabled
The value indicating if foveated rendering is enabled. Foveated rendering makes use of the eye tracking functionality in the Varjo headsets to improve performance by reducing the image quality in peripheral areas where the user is not looking. Foveation allows applications to render fewer pixels and achieve a better VR experience.
Notice
This feature is available for the Varjo devices only.
The default value is true.

string ApiName#

The name of the VR API.

VR.API ApiType#

The type of the VR API.

float HMDRefreshRate#

The refresh rate of the head-mounted display.

vec3 HandtrackingOffset#

The hand tracking offset (for the Ultraleap device only).

bool IsPeripheralRenderingModeUsed#

The value indicating if the peripheral rendering is used.

bool IsHMDConnected#

The value indicating if the head-mounted display is connected.

bool IsUsingFoveatedRendering#

The value indicating if the foveated rendering is used.

Viewport Viewport#

The viewport. It can be useful when implementing extra VR logic.

bool IsSteamVRRendersControllers#

The value indicating if the SteamVR controllers are rendered. When you access the SteamVR menu during the application runtime, the SteamVR controllers start to be rendered along with the application controllers. You can use this function to check the state of the SteamVR controllers and disable the application controllers to avoid performance drops caused by the simultaneous rendering of both controllers.

Event<bool> EventRenderModelsVisibility#

The Event triggered when the render models visibility is changed. You can subscribe to events via Connect()  and unsubscribe via Disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(bool visible)

Usage Example

Source code (C#)
// implement the RenderModelsVisibility event handler
void rendermodelsvisibility_event_handler(bool visible)
{
	Log.Message("\Handling RenderModelsVisibility event\n");
}

//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an EventConnections instance
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections rendermodelsvisibility_event_connections = new EventConnections();


// link to this instance when subscribing to an event (subscription to various events can be linked)
VR.EventRenderModelsVisibility.Connect(rendermodelsvisibility_event_connections, rendermodelsvisibility_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR.EventRenderModelsVisibility.Connect(rendermodelsvisibility_event_connections, (bool visible) => { 
		Log.Message("Handling RenderModelsVisibility event lambda\n");
		}
	);

// later all of these linked subscriptions can be removed with a single line
rendermodelsvisibility_event_connections.DisconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe to the RenderModelsVisibility event with a handler function
VR.EventRenderModelsVisibility.Connect(rendermodelsvisibility_event_handler);


// remove subscription to the RenderModelsVisibility event later by the handler function
VR.EventRenderModelsVisibility.Disconnect(rendermodelsvisibility_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////

// define a connection to be used to unsubscribe later
EventConnection rendermodelsvisibility_event_connection;

// subscribe to the RenderModelsVisibility event with a lambda handler function and keeping the connection
rendermodelsvisibility_event_connection = VR.EventRenderModelsVisibility.Connect((bool visible) => { 
		Log.Message("Handling RenderModelsVisibility event lambda\n");
	}
);

// ...

// you can temporarily disable a particular event connection 
rendermodelsvisibility_event_connection.Enabled = false;

// ... perform certain actions

// and enable it back when necessary
rendermodelsvisibility_event_connection.Enabled = true;

// ...

// remove the subscription later using the saved connection
rendermodelsvisibility_event_connection.Disconnect();

//////////////////////////////////////////////////////////////////////////////
//   4. Ignoring RenderModelsVisibility events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR.EventRenderModelsVisibility.Enabled = false;

// ... actions to be performed

// and enable it back when necessary
VR.EventRenderModelsVisibility.Enabled = true;

Event EventAudioSettingsChanged#

The Event triggered when the audio settings changed. You can subscribe to events via Connect()  and unsubscribe via Disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler()

Usage Example

Source code (C#)
// implement the AudioSettingsChanged event handler
void audiosettingschanged_event_handler()
{
	Log.Message("\Handling AudioSettingsChanged event\n");
}

//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an EventConnections instance
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections audiosettingschanged_event_connections = new EventConnections();


// link to this instance when subscribing to an event (subscription to various events can be linked)
VR.EventAudioSettingsChanged.Connect(audiosettingschanged_event_connections, audiosettingschanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR.EventAudioSettingsChanged.Connect(audiosettingschanged_event_connections, () => { 
		Log.Message("Handling AudioSettingsChanged event lambda\n");
		}
	);

// later all of these linked subscriptions can be removed with a single line
audiosettingschanged_event_connections.DisconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe to the AudioSettingsChanged event with a handler function
VR.EventAudioSettingsChanged.Connect(audiosettingschanged_event_handler);


// remove subscription to the AudioSettingsChanged event later by the handler function
VR.EventAudioSettingsChanged.Disconnect(audiosettingschanged_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////

// define a connection to be used to unsubscribe later
EventConnection audiosettingschanged_event_connection;

// subscribe to the AudioSettingsChanged event with a lambda handler function and keeping the connection
audiosettingschanged_event_connection = VR.EventAudioSettingsChanged.Connect(() => { 
		Log.Message("Handling AudioSettingsChanged event lambda\n");
	}
);

// ...

// you can temporarily disable a particular event connection 
audiosettingschanged_event_connection.Enabled = false;

// ... perform certain actions

// and enable it back when necessary
audiosettingschanged_event_connection.Enabled = true;

// ...

// remove the subscription later using the saved connection
audiosettingschanged_event_connection.Disconnect();

//////////////////////////////////////////////////////////////////////////////
//   4. Ignoring AudioSettingsChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR.EventAudioSettingsChanged.Enabled = false;

// ... actions to be performed

// and enable it back when necessary
VR.EventAudioSettingsChanged.Enabled = true;

Event<int> EventDeviceRenderModelChanged#

The Event triggered when the render model of the VR device is changed. You can subscribe to events via Connect()  and unsubscribe via Disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(int vr_device_number)

Usage Example

Source code (C#)
// implement the DeviceRenderModelChanged event handler
void devicerendermodelchanged_event_handler(int vr_device_number)
{
	Log.Message("\Handling DeviceRenderModelChanged event\n");
}

//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an EventConnections instance
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections devicerendermodelchanged_event_connections = new EventConnections();


// link to this instance when subscribing to an event (subscription to various events can be linked)
VR.EventDeviceRenderModelChanged.Connect(devicerendermodelchanged_event_connections, devicerendermodelchanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR.EventDeviceRenderModelChanged.Connect(devicerendermodelchanged_event_connections, (int vr_device_number) => { 
		Log.Message("Handling DeviceRenderModelChanged event lambda\n");
		}
	);

// later all of these linked subscriptions can be removed with a single line
devicerendermodelchanged_event_connections.DisconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe to the DeviceRenderModelChanged event with a handler function
VR.EventDeviceRenderModelChanged.Connect(devicerendermodelchanged_event_handler);


// remove subscription to the DeviceRenderModelChanged event later by the handler function
VR.EventDeviceRenderModelChanged.Disconnect(devicerendermodelchanged_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////

// define a connection to be used to unsubscribe later
EventConnection devicerendermodelchanged_event_connection;

// subscribe to the DeviceRenderModelChanged event with a lambda handler function and keeping the connection
devicerendermodelchanged_event_connection = VR.EventDeviceRenderModelChanged.Connect((int vr_device_number) => { 
		Log.Message("Handling DeviceRenderModelChanged event lambda\n");
	}
);

// ...

// you can temporarily disable a particular event connection 
devicerendermodelchanged_event_connection.Enabled = false;

// ... perform certain actions

// and enable it back when necessary
devicerendermodelchanged_event_connection.Enabled = true;

// ...

// remove the subscription later using the saved connection
devicerendermodelchanged_event_connection.Disconnect();

//////////////////////////////////////////////////////////////////////////////
//   4. Ignoring DeviceRenderModelChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR.EventDeviceRenderModelChanged.Enabled = false;

// ... actions to be performed

// and enable it back when necessary
VR.EventDeviceRenderModelChanged.Enabled = true;

Members


ivec2 GetHMDResolution ( VR.VIEWPORT_TYPE viewport_type = Enum.VR.VIEWPORT_TYPE.CONTEXT ) #

Returns the current resolution of the head-mounted display. For HMDs having context (peripheral) and focus displays, you should specify the viewport type.

Arguments

  • VR.VIEWPORT_TYPE viewport_type - Type of the viewport (for HMDs having context (peripheral) and focus displays).

Return value

HMD resolution.

bool HasFeatureMixedReality ( ) #

Returns a value indicating if the mixed reality mode is available. Mixed reality enables you to combine real-world view from front-facing cameras mounted on the headset with the VR image rendered. This feature is available for the Varjo devices only.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureEyeTracking ( ) #

Returns a value indicating if eye tracking is available. This feature is available for the Varjo devices only.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureTrackingSpaceRaw ( ) #

Returns a value indicating if poses can be provided in the coordinate system defined by the tracker driver.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureMotionPrediction ( ) #

Returns a value indicating if motion prediction is available. This feature is available for the Varjo devices only. It allows the engine to submit the velocity from the GBuffer to the Varjo Composer.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureFoveatedRendering ( ) #

Returns a value indicating if foveated rendering is available. This feature is available for the Varjo devices only. Foveated rendering enhances performance by using the eye tracking functionality in Varjo headsets: it decreases the image quality in the peripheral areas where the user is not looking. Foveation allows applications to render fewer pixels and achieve a better VR experience.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureReportProximitySensor ( ) #

Returns a value indicating if proximity sensor reporting is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureSupportForTreadmill ( ) #

Returns a value indicating if the user treadmill support is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureSupportForBaseStations ( ) #

Returns a value indicating if the base stations support is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureSupportForTrackers ( ) #

Returns a value indicating if support for trackers is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool HasFeatureSupportForRenderModelComponents ( ) #

Returns a value indicating if support for render model components is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

void ResetZeroPose ( ) #

Sets the zero pose to the current tracker position.
Last update: 2024-03-27
Build: ()