Search Unity

Target Eye & IPD

Discussion in 'AR/VR (XR) Discussion' started by EyePD, Jul 8, 2019.

  1. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    40
    When using a default VR camera rig with Target Eye set to "Both" the IPD is automatically applied to the left and right views. Is this still the case when you setup a custom rig with two separate cameras that have Target Eye set to "Left" and "Right"? In other words does each camera automatically get offset by half of the IPD or does the offset have to be manually applied by the transforms in the custom rig?

    Is there any documentation that covers how IPD is applied? I'm guessing it's been done by a modification to the view matrix but I'd like to get some more details.
     
  2. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    40
    I created a test scene in which I made two camera rigs, one stock and one split into left & right cameras. I did not attempt to manually apply any IPD adjustment; the cameras in both rigs were setup at 0, 0, 0 with scale 1, 1, 1. I switched between the two cameras and captured the output in the SteamVR headset mirror using the "Both Eyes" setting. In both cases the images were similar and both had clearly different left and right eye views so unless I can find any documentation that indicates otherwise it seems the IPD is applied automatically regardless of whether you're using a stock or split camera rig.
     
  3. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    40
    I dug into this with a little test script:

    Code (CSharp):
    1.        
    2.         Vector3 cameraPositionDiff = leftCamera.transform.localPosition - rightCamera.transform.localPosition;
    3.         Matrix4x4 leftMatrix = leftCamera.GetStereoViewMatrix(Camera.StereoscopicEye.Left);
    4.         Matrix4x4 rightMatrix = rightCamera.GetStereoViewMatrix(Camera.StereoscopicEye.Right);
    5.  
    In the debugger it was clear that cameraPositionDiff was always zero while leftMatrix and rightMatrix were different.

    Also wanted to point out that the Editor's camera preview can be misleading here; it doesn't seem to reflect the left eye or right eye view matrices even when they are split into two different camera objects with Target Eye set. I'm guessing that it's setup to always show the "center" eye. The SteamVR headset mirror is the easiest way to get an accurate preview.