VR Development
Virtual Reality (VR) is an immersive environment that makes you feel inside a virtual or digitally reproduced real 3D world.
UNIGINE offers built-in functionality for VR application development. It enables you to implement logic for various VR devices through a single API interface without using additional plugins.
See Also#
- The article on Getting Started with VR to start developing VR projects in UNIGINE.
- The section on Developing VR Applications of the Basic Introductory Course on UNIGINE real-time 3D engine.
VR System in UNIGINE#
The built-in VR system provides integration of OpenVR and Varjo.
Varjo's industrial-grade headsets with eye-tracking and mixed reality capabilities allow you to create VR and XR applications (eXtended Reality). With Mixed Reality, you can combine the real-world view from front-facing cameras mounted on the headset with the VR image.
Moreover, there is hand-tracking in VR available for Varjo VR and XR headsets through the Ultraleap integration plugin. It provides finger fidelity, two-hand performance, higher tracking robustness, and a lot of other improvements.
OpenVR is a comprehensive VR SDK (API and runtime) that allows access to VR hardware from various vendors without requiring that applications have specific knowledge of the hardware they are targeting.
So, thanks to OpenVR integration, UNIGINE supports VR development for a wide range of VR devices, including the Oculus Rift, HTC Vive, and other OpenVR-compatible devices.
Platforms#
UNIGINE enables development of VR applications for diffent VR platforms.
Oculus VR#
With UNIGINE VR system, you can implement projects for Oculus HMDs through the integration of OpenVR functionality.
For the correct work, you need to install Oculus Rift PC Runtime.
For performance profiling, you can use the Oculus PerfHud tool. It displays performance summary, including frame rate of the application and the unused hardware performance available, latency timing, application render timing, information about the HMD version, and other. To use Oculus PerfHud with UNIGINE, follow the instructions in Oculus documentation.
VR Template provides the models of the Oculus Touch and Oculus Quest controllers that are compatible with Oculus HMDs only.
SteamVR#
OpenVR integration allows you to develop projects for the SteamVR platform. It is not tied to a particular hardware: such projects can be used with any VR devices that support SteamVR.
When developing for SteamVR, first you should download and install Steam and then launch SteamVR.
For performance profiling, you can use the SteamVR Frame Timing tool.
VR Template provides the models of the following SteamVR-compatible controllers: HTC Vive, HTC Vive Pro, and HTC Vive Cosmos.
Mixed Reality Development#
Thanks to Varjo integration, you can implement Mixed Reality applications to be run with Varjo HMDs.
To develop an application, you need to install Varjo Base and SteamVR.
Mixed Reality management is performed via the VRMixedReality class of UNIGINE API.
Supported Graphics APIs#
The following graphics APIs are supported out of the box:
- DirectX 11
- DirectX 12
- Vulkan
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.
- For OpenVR:
-vr_app openvr
- For Varjo:
-vr_app varjo
Console Commands and Variables#
After initialization, a set of VR-related console commands will become available.
Description:
| |
Description:
| |
Config file: | |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Config file: | |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Config file: | |
Description:
| Arguments: [0; 200] - available range 60 - by default |
Config file: | |
Description:
| Arguments: 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) |
Config file: | |
Description:
| Arguments: 0 - mirroring is disabled. 1 - main window displays the mirrored image. (by default) |
Config file: | |
Description:
| Arguments: 0 - seated. 1 - standing. (by default) 2 - raw (uncalibrated). |
Config file: | |
Description:
| Arguments: 0 - disabled 1 - enabled (by default) |
Config file: | |
Description:
| Arguments: 0 - disabled 1 - enabled (by default) |
Config file: | |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Config file: | |
Description:
| Arguments: [eps; inf] - available range 32.0f - by default |
Config file: | |
Description:
| Arguments: [eps; inf] - available range 1.0f / 60.0f - by default |
Config file: | |
Description:
| Arguments: 0 - disabled 1 - enabled (by default) |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: vec2(0.0f, 1.0f) - default value |
Description: exposure time value that is valid for the connected device. | |
Description:
| Arguments: 0 - exposure adjustment is disabled 1 - automatic exposure adjustment (by default) 2 - manual exposure adjustment |
Description: white balance correction value that is valid for the connected device. | |
Description:
| Arguments: 0 - white balance adjustment is disabled 1 - automatic white balance adjustment (by default) 2 - manual white balance adjustment |
Description: ISO value for the camera. | |
Description:
| Arguments: 0 - ISO adjustment is disabled 1 - automatic ISO adjustment (by default) 2 - manual ISO adjustment |
Description: flicker compensation value for the camera. This is useful when using the HMD indoors with mostly artificial light bulbs, which flicker at the frequency of 50Hz or 60Hz and can cause visual flicker artifacts on the video see through image. The correct setting depends on the underlying power grid's frequency. For example, in most parts of Africa/Asia/Australia/Europe the frequency is 50 Hz and in most parts of North and South America 60 Hz. | |
Description:
| Arguments: [0; 10] - available range 0 - by default |
Description:
| Arguments: [0.0; 1.0] - available range 0.0 - by default |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Config file: | |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - Disabled (masking mode is disabled). (by default) 1 - Restrict Video to Mask (show the video pass-through image (VST) in the mask; can be used with chroma key) 2 - Restrict VR to Mask (show VR in the mask; can be used with chroma key) 3 - Restrict VR to Chromakey reduced by Mask (show VR in the mask and chroma elsewhere; requires chroma key) |
Description:
| Arguments: 0 - disabled (by default) 1 - enabled |
Description:
| Arguments: 0 - cubemap streaming from AR cameras is disabled. 1 - environment texture substitutes the sky. 2 - the first environment preset defines the way the AR texture is set for the environment. (by default) 3 - the second environment preset defines the way the AR texture is set for the environment. 4 - the third environment preset defines the way the AR texture is set for the environment. |
Description:
| Arguments: 0 - low 1 - medium (by default) 2 - high 3 - ultra |
Description:
| Arguments: 0 - correction is disabled. (by default) 1 - exposure correction for the stream from the AR cameras. 2 - exposure and white balance correction for the stream. |
VR Input#
UNIGINE VR input system provides access to a wide range of VR devices: you can manage input from VR controllers, head-mounted displays (HMDs), base stations, and trackers.
For more details on types of VR devices and their examples, check the article on VR Input System.
VR Template#
UNIGINE provides a VR template that is used to facilitate the creation of a custom application for VR. It contains a set of 3D models of popular VR controllers and the implementation of basic mechanics such as grabbing and throwing objects, pressing buttons, opening/closing drawers, and a lot more.
The template is created using the Component System, so you can easily extend its functionality.
Refer to the Getting Started with VR section to learn how to use the template for C++/C# VR project development.
Basic Workflow on Using VR#
Unlike other 3D applications, developing a VR application is more complex: you should set up a VR environment, add interactive elements, process user input from various VR devices, and so on.
The general workflow of the VR application development in UNIGINE is the following:
- Set up your UNIGINE project for VR development:
- Set up a VR device (check the instructions provided by the vendor, if necessary).
- Configure the project to use the appropriate VR mode. You can perform it via SDK Browser for C++/C# projects or in UnigineEditor for C# projects, depending on your preferred method of running your application.
- Initialize VR.
- Create the VR environment:
- Create a 3D environment for your VR project by using 3rd-party 3D modeling and level design tools and UnigineEditor.
- Extend the VR environment with animations, sounds, videos, and other interactive elements.
- Make the VR environment more interactive:
- Implement components to extend the functionality of objects in the environment and process user input.
- Use UNIGINE's VR Template (available for C++ and C# APIs) that offers a basic set of VR components and allows users to move around and interact with objects in the environment.
- Debug and profile your VR application. Use the VR platform-specific and UNIGINE built-in profiling tools to improve performance.
- Build and deploy your VR application.