cancel
Showing results for 
Search instead for 
Did you mean: 

stereoEnabled = false, GetStereoProjectionMatrix always identity in Unity 2021.2.11f1 Oculus

blascoburguillos
Honored Guest

I'm using Oculus integration installed with the XR-plugin manager with Unity 2021.2.11f1

The camera.stereoEnabled seems to always bee false, although GetStereoProjectionMatrix is true. Also GetStereoProjectionMatrix and GetStereoViewMatrix return always the identity matrix:

 

if (renderingData.cameraData.xrRendering) {
/* if (camera.stereoEnabled) { */ // Always false
    Debug.Log("Stereo enabled!");
 
    var projLeft = camera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left); // Always identity
    var viewLeft = camera.GetStereoViewMatrix(Camera.StereoscopicEye.Left); // Always identity
    viewProjLeft = projLeft * viewLeft;
    Debug.Log($"viewLeft: {viewLeft}");
    Debug.Log($"projLeft: {projLeft}");
    Debug.Log($"viewProjLeft: {viewProjLeft}");

Any idea what could be going wrong? Is this a bug or should I be getting those matrices from somewhere else?

 

Here an easy copy and paste script that can be attached to the camera to reproduce:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraTest : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        var camera = GetComponent<Camera>();
        var stereoEnabled = camera.stereoEnabled;
        Debug.Log($"Stereo enabled: {stereoEnabled}");
        var projLeft = camera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left); // Always identity
        Debug.Log($"projLeft: {projLeft}");
        var viewLeft = camera.GetStereoViewMatrix(Camera.StereoscopicEye.Left); // Always identity
        Debug.Log($"viewLeft: {viewLeft}");
    }
}

 

2 REPLIES 2

blascoburguillos
Honored Guest

It seems that on a clean project GetStereoProjectionMatrix and GetStereoViewMatrix are working fine. stereoEnabled is false always though. In a clean 2019 project it works fine, so it might be a bug. I´m trying to figure out what could break GetStereoProjectionMatrix and GetStereoViewMatrix in my main project... If anybody has a clue what could affect this, please let me know.

blascoburguillos
Honored Guest

I noticed that it works in a clean project. It stops working if the skybox material is null. I was about to report this update:

blascoburguillos_0-1645528618389.png


Setting that to null breaks GetStereoProjectionMatrix and GetStereoViewMatrix .

Could you test this with your setup too? I tested with unity 2020 and 2021