Unity + Oculus Rift: show both eyes?

时间:2015-09-14 15:26:38

标签: unity3d oculus

I'd like to be able to see the output for both eyes in Unity 5. Using the latest OVR plugin, unity only shows a single eye. Also, it appears to be rendering monoscopic even to the headset.

I'd love an example that would let me show a blue rect on the left eye, red on the right and see both (blue and red) on the primary monitor.

Suggestions?

1 个答案:

答案 0 :(得分:2)

回过头来解决了这个问题。基本上,每帧可以获得2次渲染和1次更新。

(伪代码)

int Eye=0;

Update()
{
    // reset to left eye for this frame
    Eye=0;
}

Render()
{
  // generate different content based on which view 
  // (eye, editor game view) is being rendering
  switch(Eye){
    case 0: renderLeft(); break;
    case 1: renderRight(); break;
    default: renderSomethingInEditor();
  }

  // increment to next view, will be used by next render in this frame.
  ++Eye;
}

立体渲染要求每只眼睛的视图/投影矩阵不同。眼睛被有效地视为单独的相机,稍微偏移以反映用户的IPD。所以,游戏循环运行如下:

  1. 更新()所有GameObjects
  2. 渲染()左眼的一切
  3. 渲染()右眼的一切
  4. 渲染()主显示屏上的游戏视图(如果已启用)。
  5. 转到1
  6. 在VR中,每次更新总是至少两次呈现