Problems with Object Scaling in AR

Hi there
When running in the editor we’re setting up our object and code to size a cube to fit between our UI.
Works fine when not running AR either on device or via the AR Remote solution. i.e. the cube stays the right size.
Once we connect to the test device (iOS for the moment) we’re seeing the cube distort (seemingly increase in size) it seems to be happening (thanks to being able to iterate & test using the remote) when we hit this code

m_camera.projectionMatrix = m_session.GetCameraProjection ();

in the Update Method of UnityArCameraManager.cs

Any ideas on how we can get consistency between the editor in edit mode & running without AR connected, and running it with AR Remote / on device ?

How about making the editor window the same resolution as your device screen?

Hey there @jimmya I messaged you about this particular problem earlier this week, and yes we have done the basic trouble shooting. thus why we’ve narrowed it down to that update method, we comment that line out and the cube stays the same size it is in the editor only version, remove the comment and it pops to being bigger.

I suspect its slightly trickier than a basic beginner problem.

@jimmya Any ideas?

The problem is that your in editor camera does not have the same properties as the camera on your device. That is where the camera projection matrix comes from (the FOV of the device camera, intrinsics and the resolution).

We get the camera projection matrix from ARKit projectionMatrix(for:viewportSize:zNear:zFar:) | Apple Developer Documentation

Also, you should be careful about trying to make your UI so dependent on the camera FOV since that will change per device, as well as may not be future-proof.

“Also, you should be careful about trying to make your UI so dependent on the camera FOV since that will change per device, as well as may not be future-proof.”

Which was why I wanted to make sure we had the right approach, Our UI works fine around the edge of the screen the problem we’re seeing is primarily with a 3d model we use as a Raycast target and acting as a ‘canvas/grid overlay’ for our current approach to ‘drawing’ our objects on screen/inspace.