如何为 VR 准备我的游戏? [英] How to prepare my game for VR?

查看:27
本文介绍了如何为 VR 准备我的游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一些 C++ OpenGL 游戏.它使用我们自己的渲染引擎(也不是 Unity,也不是 UE 等).让我们简化我们的问题.

Let's imagine we have some C++ OpenGL game. It uses our own engine for render (nor Unity, nor UE, etc). Let's simplify our problem.

例如,我们需要在 VR 模式下渲染一些简单的立方体.我们应该为此做什么?

For example, we need to render some simple cube in VR mode. What we should do for that?

我知道我们需要将屏幕分成两部分.但是呢?如何计算两个部分的旋转、距离?

I know we need to split our screen into two parts. But what then? How to calculate rotation, distance for both parts?

我所说的 VR 是指 VR Box、Gear VR、Oculus Rift 等设备.

By VR I mean devices such as VR Box, Gear VR, Oculus Rift, etc.

推荐答案

所有主要头显的网站上都有 API 文档,解释如何将 VR 支持集成到您的引擎中.您应该参考该文档了解详细信息.我的经验主要是使用 Oculus SDK,但其他 SDK 也类似.

All the major headsets have API documentation on their sites that explain how to integrate VR support into your engine. You should refer to that documentation for details. My experience is mostly with the Oculus SDK but other SDKs are similar.

您通常不会自己直接将屏幕一分为二——您向 SDK 提供具有左右眼视图的图像,SDK 会为镜头光学器件执行变形并将输出发送到 HMD 显示器.

You generally don't directly split the screen into two yourself - you provide images with left and right eye views to the SDK and the SDK performs warping for the lens optics and sends the outputs to the HMD display(s).

SDK 提供 API 来获取渲染每只眼睛所需的相机和视口参数.使用 Oculus SDK,您还可以通过 API 调用获取每个眼睛视图的渲染目标.您可以根据 API 提供的有关 HMD 位置、方向、视野、目标分辨率等的信息,为每个眼睛视图构建视图和投影矩阵并设置视口.

The SDK provides APIs to get the camera and viewport parameters you need to render each eye's view. With the Oculus SDK you also obtain your render targets for each eye view through API calls. You build view and projection matrices and set viewports for each eye view based on the information provided to you by the APIs for the HMD position, orientation, Field of View, target resolution, etc.

每只眼睛的渲染本质上与您在引擎中所做的任何事情相同,但当然您必须使用 SDK 提供的相机和视口信息渲染两次(每只眼睛一次),并且可能希望渲染一个在常规监视器上显示的第三个视图.您可能希望重构引擎的某些部分以提高效率,因为左右眼视图非常相似,而不是天真地将整个场景渲染两次,但这并不是绝对必要的.

Rendering for each eye is essentially the same as whatever you are already doing in your engine but of course you have to render twice (once for each eye) using the camera and viewport information provided by the SDK and may wish to render a third view for display on the regular monitor. You may want to restructure parts of your engine for efficiency since the left and right eye views are very similar rather than naively render the entire scene twice but that is not strictly necessary.

可能会在帧结束时调用,告诉 SDK 您已完成渲染并提交完成的眼部缓冲区以供显示.除此之外没有那么多.VR 渲染的大部分挑战在于实现所需的性能,而不是在显示方面相当简单的 SDK 的集成.

There will probably be a call at the end of a frame to tell the SDK you've finished rendering and submit the completed eye buffers for display. Other than that there's not that much to it. Most of the challenge of VR rendering lies in achieving the required performance not in the integration of the SDKs which are fairly simple on the display side of things.

这篇关于如何为 VR 准备我的游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆