Where are the Hololens Stereo Matices in Unity?

Is there any way in Unity to get the stereo view and projection matrices for the Hololens? I really want to save the previous frame’s view and proj matrices for various effects. I’ve tried everything I can think of:

  1. Camera.GetStereoViewMatrix and Camera.GetStereoProjectionMatrix are always identity.
  2. The camera’s transform/Camera.worldToCameraMatrix and GL.GetGPUProjectionMatrix do not produce correct View-projection matrices. In fact they are always the same for both cameras. (NOTE: I use two cameras with stereoTargetEye set to Left and Right to locate the separate camera passes)
  3. I’ve tried Material.GetMatrix(“UNITY_MATRIX_V”) and Material.GetMatrix(“UNITY_MATRIX_P”), which always fail, likely because they are packed in Constant Buffers (UnityShaderVariables.cginc).
  4. I’ve tried writing a native UWP dll that manually extracts camera poses from a HolographicFrame, yet HolographicSpace::CreateForCoreWindow barfs (SEH) because Unity has already done it for the app’s CoreWindow.

Am I missing something? These seems like fundamental data that should be readily available.

Hi @bret_alfieri ,

What version of Unity are you using? 5.5 or 5.6? Are you seeing this issue in editor or on the HoloLens itself? Thanks!

I’m on 5.5. I definitely see the issue with remote emulation. I’m fairly certain all cases are the same directly on the Hololens. Let me verify this when I get back to the office on Monday. To rule out this being a bug, what is the correct method for getting the Hololens stereo matrices? Thanks!

@BrandonFogerty ,

I switched to 5.6b3 and now camera.GetStereoViewMatrix() and camera.GetStereoProjectionMatrix() are returning non-identity matrices in both emulation mode and on the device! I’m not sure if they are correct yet, but it’s a huge improvement over identity matrices.