VR 和 XR 开发
虚拟现实(VR)是一种身临其境的环境,让您感觉置身于虚拟或数字复制的真实3D世界中。
UNIGINE offers built-in functionality for development of Virtual Reality and Mixed Reality applications. It enables you to implement logic for various VR devices through a single API interface without using additional plugins.UNIGINE为VR应用程序开发提供内置功能。它使您能够通过单个API接口实现各种VR设备的逻辑,而无需使用额外的插件。
See Also另请参阅#
- The article on Getting Started with VR to start developing VR projects in UNIGINE.关于如何在UNIGINE中开始开发VR项目的VR入门文章。
- The section on Developing VR Applications of the Basic Introductory Course on UNIGINE real-time 3D engine. UNIGINE实时3D引擎基础入门课程的 开发VR应用部分。
VR System in UNIGINEUNIGINE中的VR系统#
内置VR系统提供OpenVR和Varjo的集成。
OpenVR IntegrationOpenVR集成#
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.OpenVR是一个全面的VR SDK (API和运行时),允许访问来自不同供应商的VR硬件,而不需要应用程序具有他们所针对的硬件的特定知识。
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. The full list of supported devices is given below.因此,得益于 OpenVR 集成,UNIGINE 支持各种 VR 设备的 VR 开发,包括 Oculus Rift、HTC Vive 和其他 OpenVR 兼容设备。 下面给出了受支持设备的完整列表。
Varjo Integration and Supported FeaturesVarjo集成#
Varjo's industrial-grade headsets with eye-tracking and mixed reality capabilities allow you to create VR and MR applications. With Mixed Reality, you can combine the real-world view from front-facing cameras mounted on the headset with the VR image.具有眼动追踪和混合现实功能的工业级耳机允许您创建VR和XR(eXtended Reality)应用程序。使用混合现实技术,您可以将耳机上的前置摄像头的真实世界视图与VR图像结合起来。
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.此外,通过Ultraleap集成插件,Varjo VR和XR耳机可以使用VR中的手部跟踪功能。它提供了手指保真度、双手性能、更高的跟踪鲁棒性以及许多其他改进。
The following table lists Varjo native features that are supported by UNIGINE VR system:下表列出了UNIGINE VR系统支持的Varjo 原生特性:
Varjo 特性 | VR 系统 |
---|---|
支持的图形API | DX11, DX12, Vulkan |
人眼的分辨率 | |
眼动追踪 | |
眼动追踪参数 | |
眼摄像头数据流 | |
混合现实(MR) | |
MR环境反射 | |
MR后处理着色器 | |
MR数据流 | |
色度键控 | |
Varjo 标记 | |
深度缓冲提交 | |
速度缓冲提交 | |
多应用支持 | |
多层支持 | |
遮挡蒙版 | |
实例化呈现 | |
注视点渲染 | |
SLI兼容 |
支持的平台#
UNIGINE可以为不同的VR平台开发VR应用程序。
眼睛虚拟现实#
使用UNIGINE VR系统,您可以通过集成OpenVR功能来实现Oculus头戴式显示器的项目。
为了正确工作,您需要安装 Oculus Rift PC Runtime。
对于性能分析,您可以使用 Oculus PerfHud工具。它显示性能摘要,包括应用程序的帧率和可用的未使用硬件性能、延迟时间、应用程序渲染时间、有关HMD版本的信息等。要将Oculus PerfHud与UNIGINE一起使用,请遵循Oculus文档中的说明。
VR Template提供仅与Oculus hmd兼容的Oculus Touch和Oculus Quest控制器的模型。
SteamVR#
OpenVR集成允许您为SteamVR平台开发项目。它不绑定到特定的硬件:这样的项目可以使用任何支持SteamVR的VR设备。
在针对 SteamVR 进行开发时,首先您应该下载并安装 Steam,然后启动 SteamVR。
For performance profiling, you can use the SteamVR Frame Timing tool.对于性能分析,您可以使用SteamVR Frame Timing工具。
VR Template provides the models of the following SteamVR-compatible controllers: HTC Vive, HTC Vive Pro, and HTC Vive Cosmos.VR Template提供了以下与 SteamVR 兼容的控制器型号:HTC Vive, HTC Vive Pro和HTC Vive Cosmos。
Mixed Reality Development混合现实开发#
Thanks to Varjo integration, you can implement Mixed Reality applications to be run with Varjo HMDs.由于有了Varjo集成,您可以实现与 Varjo HMD 一起运行的Mixed Reality应用程序。
To develop an application, you need to install Varjo Base and SteamVR.要开发应用程序,需要安装Varjo Base和SteamVR。
Mixed Reality management is performed via the VRMixedReality and VRMarkerObject classes of UNIGINE API.混合现实管理是通过UNIGINE API的VRMixedReality 类执行的。
Supported Devices支持设备#
The following VR device models are supported:支持以下VR设备型号:
- Oculus Rift / Rift S / Quest / Quest 2 (带Oculus Link电缆/ Oculus Link无线)
- HTC Vive / Vive Pr / Focus / Cosmos
- Varjo VR-1 / VR-2 / VR-3 / XR-3 (扩展混合现实支持)
- Windows Mixed Reality (WMR) 兼容
- OpenVR 兼容
Supported Graphics APIs支持的图形API#
The following graphics APIs are supported out of the box:以下图形API是开箱即用的:
- 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.缺省情况下,未初始化VR。要使用VR运行引擎,需要在应用程序启动时指定-vr_app命令行选项。
- OpenVR命令:
-vr_app openvr
- Varjo命令:
-vr_app varjo
VR InputVR输入#
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.UNIGINE VR输入系统提供对广泛的VR设备的访问:您可以管理来自 VR控制器, 头戴式显示器(HMD), 基站和跟踪器的输入。
For more details on types of VR devices and their examples, check the article on VR Input System.有关VR设备类型及其示例的更多详细信息,请查看VR Input System上的文章。
VR TemplateVR 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.UNIGINE提供了一个VR Template 模板,用于方便地为VR创建自定义应用程序。它包含了一组流行的VR控制器的3D模型和基本机制的执行,如抓取和投掷物体,按下按钮,打开/关闭抽屉等等。
The template is created using the Component System, so you can easily extend its functionality.该模板是使用 Component System 创建的,因此您可以轻松地扩展其功能。
Refer to the Getting Started with VR section to learn how to use the template for C++/C# VR project development.参考VR入门文章了解如何使用C++/C# VR项目开发的模板。
Basic Workflow on Using VR使用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.与其他3D应用程序不同,开发VR应用程序更加复杂:您应该设置VR环境,添加交互元素,处理来自各种VR设备的用户输入,等等。
The general workflow of the VR application development in UNIGINE is the following:在UNIGINE中开发VR应用程序的一般流程如下:
Set up your UNIGINE project for VR development:设置VR开发的UNIGINE项目:
- Set up a VR device (check the instructions provided by the vendor, if necessary).设置VR设备(如有必要,请查看供应商提供的说明)。
- 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.配置项目以使用适当的 VR 模式。 您可以通过 SDK 浏览器(对于 C++/C# 项目)或在 UnigineEditor(对于 C# 项目)中执行此操作,具体取决于运行应用程序的首选方法。
- Initialize VR.初始化VR
Create the VR environment:创建VR环境:
- Create a 3D environment for your VR project by using 3rd-party 3D modeling and level design tools and UnigineEditor.通过使用第三方3D建模和关卡设计工具以及UnigineEditor为您的VR项目创建3D环境。
- Extend the VR environment with animations, sounds, videos, and other interactive elements.用动画、声音、视频和其他交互元素扩展VR环境。
Make the VR environment more interactive:让VR环境更具互动性:
- 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.使用 UNIGINE的VR模板(可用于C++和C# API),它提供了一组基本的VR组件,并允许用户在环境中移动和与对象交互。
- Debug and profile your VR application. Use the VR platform-specific and UNIGINE built-in profiling tools to improve performance.调试和配置您的VR应用程序。使用VR平台特定的和UNIGINE内置的分析工具来提高性能。
- Build and deploy your VR application.构建和部署您的VR应用程序。