Search Unity

Question stereoEnabled = false in Unity 2020.3

Discussion in 'VR' started by SebKpp1, Apr 23, 2021.

  1. SebKpp1

    SebKpp1

    Joined:
    Mar 6, 2019
    Posts:
    2
    Hi there,
    for our VR-Application we built a stereoscopic mirror. This works fine in Unity 2019.4.20, unfortunally it doesn't in Unity 2020.3.4
    I noticed that the camera property stereoEnabled is always false in Unity 2020. We use URP and XR Plug-in Management System in both versions with OpenVR Plugin. Stereo Rendering Mode is set to Single Pass Instanced.

    In Unity 2019 everything was fine and we could access the stereo view and projection matrizes. Can anyone explain what cause this behavior in 2020?

    Code (CSharp):
    1. public class StereoTest : MonoBehaviour
    2. {
    3.     // Update is called once per frame
    4.     void Update()
    5.     {
    6.         Camera cam = GetComponent<Camera>();
    7.  
    8.         if (cam.stereoEnabled) // Not working in Unity 2020 Single Pass
    9.         {
    10.             Debug.Log("Stereo enabled!");
    11.  
    12.             Matrix4x4 _leftEyeViewMatrix = cam.GetStereoViewMatrix(Camera.StereoscopicEye.Left);
    13.             Matrix4x4 _rightEyeViewMatrix = cam.GetStereoViewMatrix(Camera.StereoscopicEye.Right);
    14.  
    15.             Matrix4x4 _leftEyeProjectionmatrix = cam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
    16.             Matrix4x4 _rightEyeProjectionmatrix = cam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
    17.         }
    18.         else
    19.         {
    20.             Debug.Log("Stereo not enabled!");
    21.         }
    22.     }
    23. }
     
    david-mal and erw29 like this.
  2. SebKpp1

    SebKpp1

    Joined:
    Mar 6, 2019
    Posts:
    2
    Something odd I have noticed, cam.stereoEnabled is always false, while UniversalRenderingPipeline.IsStereoEnabled returns true.

    Nevertheless cam.GetStereoProjectionmatrix() returns a valid Matrix, but only if camera uses background type "Skybox". Onces its set to "Solid Color", GetProjectionMatrix() returns an Identity-Matrix.

    But for using our Project in AR as well we depend on setting it to "Solid Color"