googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.09k forks source link

Camera horizontally stretched when switching from VR Cardboard to VR None #640

Closed peterept closed 6 years ago

peterept commented 7 years ago

Hi,

When I exit cardboard mode I use VRSettings.LoadDeviceByName("None"); wait til next frame and call VRSettings.enabled = true;.

When I do this I am back in mono mode, but the screen is stretched horizontally to double (like I am seeing a single eye but double width on the screen).

I'm using Unity 5.6.1p4.

I tried reseting the camera's projectionMatrix, and whilst it does fix the distortion - I can't use this as a fix because then I can't enable the user to zoom via the camera's fieldOfView setting.

Is there another work-around?

peterept commented 7 years ago

For anyone else, I found a work-around using 2 cameras:

Then any cardboard distortions on the VR camera won't effect the non-vr camera.

antoniohof commented 7 years ago

I think this is the same as this: #628 Just call Camera.main.ResetAspect (); after entering monoscopic mode, as stated by @noemis84

peterept commented 7 years ago

Thanks. I can confirm it is the same problem and that Camera.main.ResetAspect (); does fix it.

BUT, that work-around on IOS leave a frame where the distortion is visible and then it is fixed - which is very ugly and makes the app look buggy.

I ended up using this solution (over the 2 camera approach) because it made my logic for camera management easier.

However, to avoid the 1 frame of distortion, I use a black overlay to fade out the screen, then switch out of cardboard, then fade it back in thus hiding the frame.

Thanks for your response.

fredsa commented 7 years ago

You mentioned setting VRSettings=true (rather than false), which is not what you want, although I don't think that this would cause the wrong aspect issue from appear briefly.

To make sure that's not the case, can you try you the SwitchOutOfVr() coroutine from https://github.com/googlevr/gvr-unity-sdk/wiki/Switching-between-VR-and-non-VR-at-runtime and confirm whether you still see the incorrect aspect ratio during switching?

Note that there are effectively two ways to leave VR:

  1. Set VRSettings=false (but leave the Cardboard VR SDK active so you can later set this setting back to true)
  2. Call VRSettings.LoadDeviceByName("") (meaning the None device), which will automatically also set VRSettings=false.
fredsa commented 7 years ago

You can vote on the Unity issue which is causing you to have to call ResetAspect() here: https://issuetracker.unity3d.com/issues/android-vrcardboard-aspect-ratio-not-preserved-when-switching-from-vr-cardboard-to-non-vr-vrsettings-dot-enabled-equals-false

fredsa commented 6 years ago

Duplicate of #628

This is fixed in:

Unity 5.6.4p2 and later Unity 2017.1.2p3 and later Unity 2017.2.0p2 and later

This means that you should no longer have call ResetAspect() after switching out of VR.