engine.vr Functions
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
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.
Supported Graphics APIs#
The following graphics APIs are supported out of the box:
- DirectX 11
- DirectX 12
- Vulkan
For OpenGL API support, use the corresponding VR plugins (deprecated).
VR Class
Members
void setRenderEnabled ( int enabled ) #
Console: vr_render_enabled
Sets a new value indicating if rendering into the head-mounted display is enabled. This parameter is stored in the following configuration file: *.boot .
Arguments
- int enabled - The rendering into the HMD The default value is false.
int isRenderEnabled() const#
Console: vr_render_enabled
Returns the current value indicating if rendering into the head-mounted display is enabled. This parameter is stored in the following configuration file: *.boot .
Return value
Current rendering into the HMD The default value is false.void setPeripheralRenderingModeEnabled ( int enabled ) #
Console: vr_peripheral_rendering_mode_enabled
Sets a new 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.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Arguments
- int enabled - The the peripheral rendering mode The default value is false.
int isPeripheralRenderingModeEnabled() const#
Console: vr_peripheral_rendering_mode_enabled
Returns the current 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.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Return value
Current the peripheral rendering mode The default value is false.void setMirrorMode ( int mode ) #
Console: vr_mirror_mode
Sets a new mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. This parameter is stored in the following configuration file: *.boot .
Arguments
- int 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 getMirrorMode() const#
Console: vr_mirror_mode
Returns the current mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. This parameter is stored in the following configuration file: *.boot .
Return value
Current 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)
void setWindowMode ( int mode ) #
Console: vr_window_mode
Sets a new window mode that defines which window will display the mirrored image (i.e. VR image). This parameter is stored in the following configuration file: *.boot .
Arguments
- int 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)
int getWindowMode() const#
Console: vr_window_mode
Returns the current window mode that defines which window will display the mirrored image (i.e. VR image). This parameter is stored in the following configuration file: *.boot .
Return value
Current 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)
void setTrackingSpace ( int space ) #
Console: vr_tracking_space
Sets a new zero pose of the tracking origin. This parameter is stored in the following configuration file: *.boot .
Arguments
- int space - The zero pose of the tracking origin. One of the following values:
- 0 - seated.
- 1 - standing. (by default)
- 2 - raw (uncalibrated).
int getTrackingSpace() const#
Console: vr_tracking_space
Returns the current zero pose of the tracking origin. This parameter is stored in the following configuration file: *.boot .
Return value
Current zero pose of the tracking origin. One of the following values:- 0 - seated.
- 1 - standing. (by default)
- 2 - raw (uncalibrated).
void setMotionPrediction ( int prediction ) #
Console: vr_motion_prediction
Sets a new 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. This parameter is stored in the following configuration file: *.boot .
Arguments
- int prediction - The motion prediction The default value is false.
int isMotionPrediction() const#
Console: vr_motion_prediction
Returns the current 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. This parameter is stored in the following configuration file: *.boot .
Return value
Current motion prediction The default value is false.void setMotionPredictionVelocityPrecision ( float precision ) #
Sets a new factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Arguments
- float precision - The factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
Range of values: [eps, inf]. The default value is : 32.0f.
float getMotionPredictionVelocityPrecision() const#
Returns the current factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Return value
Current factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).Range of values: [eps, inf]. The default value is : 32.0f.
void setMotionPredictionVelocityTimeDelta ( float delta ) #
Sets a new factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Arguments
- float delta - The factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
Range of values: [eps, inf]. The default value is : 1.0f / 60.0f.
float getMotionPredictionVelocityTimeDelta() const#
Returns the current factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Return value
Current factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.Range of values: [eps, inf]. The default value is : 1.0f / 60.0f.
void setFoveatedRenderingEnabled ( int enabled ) #
Console: vr_foveated_rendering_enabled
Sets a new 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.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Arguments
- int enabled - The foveated rendering The default value is true.
int isFoveatedRenderingEnabled() const#
Console: vr_foveated_rendering_enabled
Returns the current 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.
This parameter is stored in the following configuration file: *.boot .
This feature is available for the Varjo devices only.
Return value
Current foveated rendering The default value is true.string getApiName() const#
Returns the current name of the VR API.
Return value
Current name of the VR API.int getApiType() const#
Returns the current type of the VR API.
Return value
Current type of the VR API.float getHMDRefreshRate() const#
Returns the current refresh rate of the head-mounted display.
Return value
Current refresh rate of the HMD.Vec3 getHandtrackingOffset() const#
Returns the current hand tracking offset (for the Ultraleap device only).
Return value
Current hand tracking offset.int isPeripheralRenderingModeUsed() const#
Returns the current value indicating if the peripheral rendering is used.
Return value
Current the peripheral rendering is usedint isHMDConnected() const#
Returns the current value indicating if the head-mounted display is connected.
Return value
Current the HMD is connectedint isUsingFoveatedRendering() const#
Returns the current value indicating if the foveated rendering is used.
Return value
Current the foveated rendering is usedViewport getViewport() const#
Returns the current viewport. It can be useful when implementing extra VR logic.
Return value
Current viewport.int isSteamVRRendersControllers() const#
Returns the current 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.
Return value
Current the SteamVR controllers are renderedstatic Event<bool> getEventRenderModelsVisibility() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.static getEventAudioSettingsChanged() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.static Event<int> getEventDeviceRenderModelChanged() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.ivec2 engine.vr.getHMDResolution ( int 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
- int viewport_type - Type of the viewport (for HMDs having context (peripheral) and focus displays).
Return value
HMD resolution.int engine.vr.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.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureEyeTracking ( ) #
Returns a value indicating if eye tracking is available. This feature is available for the Varjo devices only.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureTrackingSpaceRaw ( ) #
Returns a value indicating if poses can be provided in the coordinate system defined by the tracker driver.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.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.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.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.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureReportProximitySensor ( ) #
Returns a value indicating if proximity sensor reporting is available.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureSupportForTreadmill ( ) #
Returns a value indicating if the user treadmill support is available.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureSupportForBaseStations ( ) #
Returns a value indicating if the base stations support is available.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureSupportForTrackers ( ) #
Returns a value indicating if support for trackers is available.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.int engine.vr.hasFeatureSupportForRenderModelComponents ( ) #
Returns a value indicating if support for render model components is available.If VR is not initialized, the function will return false.
Return value
true if the feature is available; otherwise, false.void engine.vr.resetZeroPose ( ) #
Sets the zero pose to the current tracker position.Last update:
2024-03-27
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)