Vr mode with mono camera

Hi there.

Is it possible to enable Unity native VR mode for a given SDK (let’s say cardboard) and render in mono mode (like in a non-vr app, with a single camera output across the screan instead the ‘left-eye, right-eye’ style).

Specifically what I need for my app is to use the gyro input to rotate the camera but in a non-vr app. In the future I might need to change from non-vr to vr render mode.

Regards

VRSettings.enabled = false;
Camera.main.rotation = InputTracker.GetLocalRotation(VRNode.CenterEye);

Something like that, look up the InputTracker class
You should have the cardboard SDK loaded though in order for this to work.

This is called magic window mode, this is somewhere written in the Unity manual under Google VR

1 Like

It works like a charm. Thanks!!

Camera is rotating properly but something weird is happening when running from the handset. It seems to apply a kinda zoom (I guess decreasing FOV though setting a different FOV at runtime changes nothing) and it also distort the image. The funny thing is that if I lock the handset and then resume the application then camera is working nice, with no distortion neither zoom (see screen captures at the bottom)

Any idea about what is happening and how it can be resolved?

Before lock the app:

As you can see the image is stretched across screen diagonal.

After blocking and resuming:

Now there is no zoom neither stretching




1 Like

You can try to fix it by resetting the camera matrix. Though Unity currently has quite some bugs in GVR.
On iOS this rotation isn’t even correct. In the app we’re creating the Z axis gets rotated when entering VR etc.
I’ve talked about it in some other thread as there are a lot of threads with ppl trying to get to use GVR right. But it is mostly because of bugs that things are not as developers want them to be. Would be nice if the bugs got fixed, ever since release of 5.6 native integration it has been buggy.

1 Like

Thanks. I found that calling to ‘camera.ResetAspect()’ after setting VrSettings.enabled to false seems to set camera with the proper FOV and no distortion

1 Like

You can vote on this issue here:

Hi everyone, so I just found this and wanted to try it myself, 'cause I want a non-stereoscopic view with head tracking applied, but it doesn’t work. The Video is “frozen” and I can’t move around. Any ideas why this could be?

The magic window mode requires you to load the cardboard sdk

Well, I installed the cardboard sdk… Should I provide any screenshots? (from code??)

Here’s the code:

public class test : MonoBehaviour {

    // Use this for initialization
    void Start () {
        VRSettings.enabled = false;
        Camera.main.ResetAspect();
        Camera.main.GetComponent<Transform>().localRotation = InputTracking.GetLocalRotation(VRNode.CenterEye);
    }
   
    // Update is called once per frame
    void Update () {
       
    }
}

Here are some Screenshots from my project:

3228610--247723--Folders.PNG
3228610--247724--scene.PNG
3228610--247725--camera.PNG
3228610--247726--sphere_1.PNG
3228610--247727--sphere_2.PNG

Nevermind. Problem solved by moving the code into the update method

1 Like

Problem with this approach is before screen is loaded, view is stereoscopic, because changes happen only on Start or OnEnable methods. How can I disable stereoscopic view from the beginning? I don’t want to use it at all.

You can set ‘None’ as your first VR SDK in XR settings (VR Settings in older Unity versions) like this:

As Unity try to load a proper SDK for your available devices as ordered in the list it always will load ‘None’ so, when you launch your app, stereoscopic camera should be disabled (the same for any VR behaviour). From here you can set up the vr behaviour (stereo camera, head tracking…) at your will.

Keep in mind that, at some point, you will need to load your VR SDK. This can be done with XRSettings.LoadDeviceByname (VRSettings.LoadDeviceByName in older unity)

1 Like

Being shot from just one perspective or 2 if in stereo, you can’t really move around in a video, right? Rotating should not be a problem though.