Search Unity

ARCameraBackground affecting Frustrum?

Discussion in 'AR' started by Duckocide, Sep 27, 2020.

  1. Duckocide

    Duckocide

    Joined:
    Aug 30, 2014
    Posts:
    35
    Hi

    Can anybody help. I'm using ARCore (and the third party "AR Foundation Remote" asset for sensor input). Everything is working but I've come across an issue I can't seem to fathom (have narrowed the cause, the ARCameraBackground script, but wondering the best way to remedy the issue).

    I have an "AR Session Origin" object with the usual scripts attached

    upload_2020-9-27_23-8-23.png

    This in turn has an AR Camera object with the following attached...
    upload_2020-9-27_23-9-45.png

    I'm then attaching another camera to this one for some special (unique layer objects) RenderTexture creation for some next frame shader input (it's an alpha clipping / emissive effect to neaten and dress up the edge of the game area).

    upload_2020-9-27_23-14-21.png

    This "Visualisation Mask" (as I've called it) camera is local pos, eular of zero, scale of 1 and is (via a script) tracking the near, far and field of view of the AR Session Camera. The theory being that the visualisation camera should render a texture with the same object projection as the AR Session origin camera (Render texture has a 16:9 ratio matching the desired game ratio).

    This is where my issue lies, the "Visualisation Mask" texture I get a different projection to the AR Session Camera. Moreover, in the scene window, it has a different frustrum (despite values being apparently aligned).

    When I disable the "AR Camera Background" script, all is well? Leading me to believe it's doing something to the AR Session Camera render (projection matrix)? Checking the script, it does seem to receive a matrix and use it (not dug in too far).

    So, is there any way of getting a secondary camera to match the projection of the AR Session Camera?

    ... I wondered if the only real way out of this is to inherit the ARCameraBackground script and intercept the matrix received (override OnCameraFrameReceived()...) and make the matrix accessible to the secondary camera tracking script)?
     
    KyryloKuzyk likes this.
  2. Duckocide

    Duckocide

    Joined:
    Aug 30, 2014
    Posts:
    35
    OK. So as ever, talking it thru on a post kinda indicated the solution. Setting the projectionMatrix on the secondary camera to the AR Session Camera sorted out the issue. The render texture is now accurate to the AR Session Camera view.
     
    KyryloKuzyk likes this.