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

Resolved AR Camera's Children Displacement

Discussion in 'AR' started by klimentiy98, Oct 8, 2021.

  1. klimentiy98

    klimentiy98

    Joined:
    Apr 12, 2020
    Posts:
    2
    There is an issue with offset of the child object relative to the camera on mobile device. I have created a simple scene as an example to show the problem with the following hierarchy.

    upload_2021-10-8_20-52-8.png

    Red crosshair at the center of the local canvas attached to the camera, and white point at the center of the screen overlay canvas. So there how these markers look like in the simulator - both in the center of the screen, logically.

    upload_2021-10-8_22-19-0.png

    But this is what I see on my device.

    upload_2021-10-8_22-33-41.jpeg

    Another one.

    upload_2021-10-8_22-34-47.jpeg

    The white point is exactly in the center of the screen, but AR Camera's child has a small offset (I used local canvas for better representation, but problem also remains for 3d objects). There are different offsets for different device screens.
    Have no idea what can cause this displacement. It doesn't look like a position offset, but like cropped rendering of AR Camera's child objects. Hope there should be an acceptable solution :)
     
    dimitris_baud likes this.
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,128
    I was able to reproduce the same behavior. I determined it's caused by the ARCameraFrameEventArgs.projectionMatrix.
    AR Foundation modifies ARCamera's projection matrix to match the projectionMatrix coming from a native AR provider.

    Weirdly enough, the displacement is only happening with enabled Plane Tracking (tested only on iOS).

    Moreover, the projectionMatrix is always changing on iOS. At first, I thought it may be connected to Auto Focus, but even with disabled Auto Focus, the projectionMatrix is changing slightly when you move the device around.
     
  3. klimentiy98

    klimentiy98

    Joined:
    Apr 12, 2020
    Posts:
    2
    Thanks for your reply.

    I have discovered some new stuff about how ARCamera works. But I couldn't find a way to control projection matrix directly (and I don't think its necessary).

    To solve my issue I've just added a local camera down the ARCamera hierarchy, which renders only local objects (AR camera renders everything else, respectively). So I got the result I needed, but not sure its the best one.