I have been forwarded here but Unity AR Foundation Team Staff as they don’t seem to be able to explain how to do this (bit concerning).
I am trying to replicate some of the functionality of the ARKitBackground shader where it applies some form of displayMatrix 4x4 to the AR Camera Background image as you can see in my gif below, the Stencil mask received from the DisplayDepth script in AR Foundation Samples doesn’t match up with the onscreen camera image provided by the AR Camera Background component through the ARKitBackground Shader it uses on IOS.
The AR Camera is almost more zoomed in or scaled but also offsetted. This effect is only noticeable on Iphone, on Ipad the aspect ratio of the AR Camera Background matches very closely with the Stencil cutout image so I only found this issue when testing my app on an iphone. I want to use both the stencil and ar cam background textures in shader graph for an effect, an have them both line up as well as they can as I am currently doing that but they do not line up on Iphones.

I currently have a shader graph where I nab the AR Camera Background renderer texture using:
Graphics.Blit(null, targetRenderTexture, m_ARCameraBackground.material);
Then separately, using the DisplayDepthImage.cs script from ARF samples, I save out that onscreen hand stencil texture to the same shader graph and overlay them buuut… obviously things do not line up on iphone. It works fantastic on ipad which is annoying.
I have been advised to recreate this line from the ARKitBackgroundShader in shader graph but I am fully stumped on how to do this as there is not much documentation of how the shader uses the Matrix 4x4 there:
// Remap the texture coordinates based on the device rotation.
float2 texcoord = mul(float3(v.texcoord, 1.0f), _UnityDisplayTransform).xy;
I have read - ARCameraFrameEventArgs.displayMatrix -
displayMatrix
Gets or sets the display matrix for use in the shader used by the ARCameraBackground. Use displayMatrix.HasValue to determine if this data is available.
Any help or tips on this would be really appreciated!

