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:
    63
    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:
    63
    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:
    63
    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.
     
  4. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    102
    Hello, I'm interested in this as well.

    Have you discovered if there is a different between having two separate eye cameras vs "both" in terms of the final composited image?

    Also, is there a way to adjust the IPD at runtime through script?

    In the documentation:
    https://docs.unity3d.com/ScriptReference/Camera-stereoSeparation.html

    It says "Note that most VR devices provide this value, in which case setting the value will have no effect."
     
  5. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Hi there

    When using the XR Rig, is there any way to make the scene feel smaller or bigger?
    I've tried scaling the camera, which works in principle but then I need to scale all my in game UI, and the hand controllers.

    It would be great if we can just set this IPD and then the only difference would be what one would expect it to be.

    Anyone else have any insight into how this is done?

    Thanks in advance
    Brian