Search code examples
unity-game-engineoculusvirtual-reality

Viewport in unity with Oculus Rift


I have set up a window to spread across 2 monitors horizontally. I have 2 viewports. The first is a standard Camera. I have set this to half the width of the window so that it is 1920x1080 (filling the first monitor). The problem I have is that I want to Oculus viewport to take up the 2nd monitor ). However, I cannot find the setting to stop the oculus viewport from taking up the full window.

Can anybody help?

Images for clarification

What it currently looks like:

http://imgur.com/WEl9Uaj

What I would like it to look like:

http://imgur.com/TMjXMkA

I am guessing it is somewhere in the script, but I cannot see where the viewports are drawn.

Any help would be appreciated.


Solution

  • In typical form, I have found the answer after a few minutes of posting this.

    for anybody who needs this in future, open OVRDistortionCamera.cs and find the lines

    float halfWidth = 0.5f * Screen.width;
        GL.Viewport(new Rect(rightEye ? halfWidth : 0f, 0f, halfWidth, Screen.height));
    

    Change them to

    float halfWidth = 0.5f * Screen.width/2;
        GL.Viewport(new Rect(rightEye ? halfWidth : 0f, 0f, halfWidth, Screen.height));