Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Where are the Hololens Stereo Matices in Unity?

Discussion in 'VR' started by bret_alfieri, Jan 6, 2017.

  1. bret_alfieri

    bret_alfieri

    Joined:
    Oct 5, 2016
    Posts:
    5
    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.
     
  2. BrandonFogerty

    BrandonFogerty

    Joined:
    Jan 29, 2016
    Posts:
    83
    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!
     
  3. bret_alfieri

    bret_alfieri

    Joined:
    Oct 5, 2016
    Posts:
    5
    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!
     
  4. bret_alfieri

    bret_alfieri

    Joined:
    Oct 5, 2016
    Posts:
    5
    @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.
     
    Last edited: Jan 10, 2017