3Dave
3Dave

Reputation: 29051

Unity + Oculus Rift: show both eyes?

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?

Upvotes: 3

Views: 1524

Answers (1)

3Dave
3Dave

Reputation: 29051

Solved this awhile back. Basically, you get 2 renders and 1 update per frame.

(Pseudocode)

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;
}

Stereo rendering requires that the view/projection matrices are different for each eye. The eyes are effectively treated as separate cameras that are slightly offset to reflect the user's IPD. So, the game loop runs like this:

  1. Update() all GameObjects
  2. Render() everything for left eye
  3. Render() everything for right eye
  4. Render() Game View on primary display, if enabled.
  5. Goto 1

You will always get at least two renders per update in VR.

Upvotes: 2

Related Questions