使用单视角渲染提高性能
立体渲染的一个显著成本是渲染两个视图,分别对应每个眼睛。
对于一些应用程序来讲,立体渲染可能不是特别重要,并且为了提高一些性能使用单视角也是可以接受的。在其他情况下,立体视图可能会给一些用户带来用眼疲劳,他们会希望切换成单视角。即便如此,他们也仍然希望戴上能给他们提供大视场和头部跟踪的HMD(译者注:FOV–Field Of View 视野、视场;在刘越教授的透视式头盔显示器的设计及评测.ppt中使用了“视场”)
OculusWorldDemo允许用户单击F7键来切换渲染模式。
使用单视角渲染方式,你需要在你的代码中做以下调整:
- 将视场设置成基于双眼的最大的对称视场
- 对FOV调用ovhHmd_GetFovTextureSize函数来决定推荐的渲染对象大小
- 调用ovr_SubmitFrame或者ovr_GetRenderScaleAndOffset使双眼使用相同的渲染对象和视区
- 将场景渲染到共享渲染对象一次
这会将左右眼的视角合到一个单一的中间渲染层上。这个渲染仍然会扭曲两次,每只眼睛一次,因为透镜并不完全是在眼睛的正前方。即便如此,这仍是重要的性能提升。
将虚拟瞳距(译者注:IPD:Insertion Phase Delay)设置为零就意味着一切都会显得过于巨大并且无限遥远,用户在场景中就会因此失去了深度感。
注:虚拟瞳距与虚拟头部运动的匹配很重要,如果虚拟瞳距被设置为零,所有的由颈部运动产生的虚拟头部运动都会被消除。遗憾的是,这会丢失很多由视差产生的深度线索。但是如果头部运动和瞳距不一致将会造成重大的迷惑和不适。谨慎试验!
原文如下
Improving Performance by Rendering in Mono
A significant cost of stereo rendering is rendering two views, one for each eye.
For some applications, the stereoscopic aspect may not be particularly important and a monocular view might be acceptable in return for some performance. In other cases, some users may get eye strain from a stereo view and wish to switch to a monocular one. However, they still wish to wear the HMD as it gives them a high FOV and head-tracking.
OculusWorldDemo allows the user to toggle mono render mode by pressing the F7 key.
To render in mono, your code should have the following changes:
- Set the FOV to the maximum symmetrical FOV based on both eyes.
- Call ovhHmd_GetFovTextureSize with this FOV to determine the recommended render target size.
- Configure both eyes to use the same render target and the same viewport when calling ovr_SubmitFrame or ovr_GetRenderScaleAndOffset.
- Render the scene once to the shared render target.
This merges the FOV of the left and right eyes into a single intermediate render. This render is still distorted twice, once per eye, because the lenses are not exactly in front of the user’s eyes. However, this is still a significant performance increase.
Setting a virtual IPD to zero means that everything will seem gigantic and infinitely far away, and of course the user will lose much of the sense of depth in the scene.
Note: It is important to scale virtual IPD and virtual head motion together so, if the virtual IPD is set to zero, all virtual head motion due to neck movement is also be eliminated. Sadly, this loses much of the depth cues due to parallax. But, if the head motion and IPD do not agree, it can cause significant disorientation and discomfort. Experiment with caution!