Search Unity

Disable Stereo rendering with Cardboard (and Gear) SDK

Discussion in 'AR/VR (XR) Discussion' started by danielesuppo, Sep 24, 2017.

  1. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Hello!
    I'm working on a video player applications for some 360 videos.
    I should put some 3D animated graphics on top of them in Unity, but I don't want them to show in stereo rendering because them look very weird with the videos in background.
    So I'd like to keep the spiltted view for both eyes (so VR enabled), but to avoid the stereoscopic rendering (so basically I'd like both views to show the same rendering).

    The variable Camera.stereoEnabled is read-only, so I can't change it by script.
    I've tried with "Stereo Separation" = 0 in Camera inspector parameters, but it seem it has no effect, just like "Stereo Convergence"...

    I googled a bit to find some help but it seem that everyone, talking about "stereoscopic" and "monoscopic", means VR enabled or not, that's not what I mean.
    Maybe someone have some good solution?
    Many thanks!
     
    Last edited: Sep 24, 2017
  2. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    Code (CSharp):
    1. void Start()
    2. {
    3.     StartCoroutine( LoadDevice( "cardboard" ) );
    4. }
    5.  
    6. IEnumerator LoadDevice( string newDevice )
    7. {
    8.     VRSettings.LoadDeviceByName( newDevice );
    9.     yield return null;
    10.     VRSettings.enabled = false;
    11. }
    12.  
    13. void Update()
    14. {
    15.     GetComponent<Camera>().transform.localRotation = InputTracking.GetLocalRotation( VRNode.CenterEye );
    16.     GetComponent<Camera>().ResetAspect();
    17. }
    18.  
    https://forum.unity.com/threads/vr-mode-with-mono-camera.479031
     
  3. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Thank-you Gerold_Meisinge,
    with "VRSettings.enabled = false;" the Cardboard does not work anymore (it's just the standard view),
    but with "VRSettings.enabled = true;" it seem to work as expected.
    The only issue is that now the camera point upwards (the sky) and unfortunately I can't rotate all my scene...
    Any advice to have the camera with the right rotation?
    Thank-you!
     
  4. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Hello,
    I think I've solved the issue parenting the camera to another GameObject that will be rotated if the camera has wrong rotation

    Code (CSharp):
    1. public class DisableStereoRendering : MonoBehaviour {
    2.  
    3.     public GameObject pivotCamera;
    4.  
    5.     void Start()
    6.     {
    7.         StartCoroutine( LoadDevice( "cardboard" ) );
    8.     }
    9.  
    10.     IEnumerator LoadDevice( string newDevice )
    11.     {
    12.         VRSettings.LoadDeviceByName( newDevice );
    13.         yield return null;
    14.         VRSettings.enabled = true;
    15.     }
    16.  
    17.     void Update()
    18.     {
    19.         if (gameObject.transform.localEulerAngles.x > 30f) {
    20.             pivotCamera.transform.eulerAngles = new Vector3 (-90f, 0, 0);
    21.         }
    22.         GetComponent<Camera>().transform.localRotation = InputTracking.GetLocalRotation( VRNode.CenterEye );
    23.         GetComponent<Camera>().ResetAspect();
    24.     }
    25. }
     
  5. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    The point of VRSettings.enable = false is to deactivate the stereo rendering while VRNode.CenterEye will still be updated with the correct rotation which you should apply to your own camera.
     
  6. Renewalz

    Renewalz

    Joined:
    Jul 2, 2017
    Posts:
    2
    how would I accomplish this now with the new API and XR?
     
  7. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    Necro post, much?

    What platform are you targetting?
     
  8. Renewalz

    Renewalz

    Joined:
    Jul 2, 2017
    Posts:
    2
    Android for now and eventually iOS.