Hey,
I’ve run into an issue with having a second camera not matching the AR Camera having the AR Camera Background on it.
i am using that second camera in my scene - set to clear depth. I am copying the Camera Matrix by script from the AR Camera which is having the AR Camera Background Script on it. I think the problem is that besides the Projection Matrix additional (un)distortion is done through a Shader so it matches the Device Camera closer (ipad pro in my case). I am using that second Camera to make stuff appear around a target using Depth Masking etc. Problem is that the mismatch (due to that distortion) is really visible.
Is there a provided way within ARFoundation of setting up that second camera with the distortion? Or do i need to write a shader that applies that matrix during Post on the second camera?
The relevant code in ARCameraBackground Script looks like this:
void OnCameraFrameReceived(ARCameraFrameEventArgs eventArgs)
{
UpdateMaterial();
var mat = material;
var count = eventArgs.textures.Count;
for (int i = 0; i < count; ++i)
{
mat.SetTexture(
eventArgs.propertyNameIds[i],
eventArgs.textures[i]);
}
mode = ARRenderMode.MaterialAsBackground;
if (eventArgs.displayMatrix.HasValue)
mat.SetMatrix(k_DisplayTransformId, eventArgs.displayMatrix.Value);
if (eventArgs.projectionMatrix.HasValue)
m_Camera.projectionMatrix = eventArgs.projectionMatrix.Value;
}
Where the part i think causing my mismatch is that:
mat.SetMatrix(k_DisplayTransformId, eventArgs.displayMatrix.Value);
Camera Setup
Any help is appreciated!