Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OVRCameraRig.rightEyeCamera.projectionMatrix seems incorrect

Discussion in 'AR/VR (XR) Discussion' started by jobigoud, Oct 11, 2017.

  1. jobigoud

    jobigoud

    Joined:
    Apr 13, 2017
    Posts:
    8
    Hi,

    The simplest way to verify there is a problem is that if you print out the values of OVRCameraRig.leftEyeCamera.projectionMatrix and OVRCameraRig.rightEyeCamera.projectionMatrix, they have the same coefficients, while they should be different as we are in parallel stereo/asymmetric frusta.

    In my scenario I'm using these projection matrices to render a scene in an external renderer and merge it back in Unity. The left eye projection matrix is perfect, the right eye projection is slightly wrong. Close objects are well aligned with local Unity objects but the further from the camera the more divergence.

    This points to me that the Unity renderer doesn't internally use OVRCameraRig.rightEyeCamera.projectionMatrix for its own rendering, and that this matrix is actually the projection for the left eye. How can I get the correct right eye projection matrix used by Unity?

    I'm using single pass stereo, the OVRCameraRig is from Oculus Unity Utilities v1.18.1 but the same issue existed with older versions. Unity 2017.1.1.

    I also tried Camera.GetStereoProjectionMatrix(Camera.StereoscopicEye), but again this returns the same projection matrix for both eyes which is wrong.

    I also tried OVRPlugin.GetEyeFrustum(eyeId) but this returns a Frustumf which is a symmetric frustum by construction and thus cannot be the correct projection matrix.

    I also tried to use OVRPlugin.CalculateLayerDesc because the LayerDesc structure contains a Fovport for each eye (the tan angles in each direction), but the fov port is not filled in by that function.
     
    Last edited: Oct 11, 2017
  2. jobigoud

    jobigoud

    Joined:
    Apr 13, 2017
    Posts:
    8
    Oh, hum. So it does work when using Camera.GetStereoProjectionMatrix(). I'm still confused that both eyes are using the same projection matrix.