Search Unity

AR Camera Background with Screen Space Camera Canvas not working

Discussion in 'Handheld AR' started by artfabrik, Jan 21, 2019.

  1. artfabrik

    artfabrik

    Joined:
    Jun 6, 2018
    Posts:
    4
    Hey,

    I'm trying to get the AR Camera Background of AR Foundation to work with a Canvas that has the renderMode 'Screen Space Camera'.
    The Canvas contains some UI.
    But when used with the Component AR Camera Background, the content of the Canvas doesn't show up.
    Currently only renderMode 'Screen Space Overlay' is displayed correctly, but this has the problem, that it doesn't render into the RenderTexture (which I need for smooth scene transitions)
    I have read that it might be possible by using multiple Cameras, but I'd like to avoid this due to readability/maintainability of our code.
    I have also tried a test canvas with the new LWRP Background renderer: https://forum.unity.com/threads/arfoundation-now-supports-lwrp-4-8-0-preview.615109/
    but this seems to have the same problem.

    So first: Is my idea maybe even perhaps possible with a Screen Space Overlay? This would be better anyway, because it is 'always' on top instead of using the depth buffer with a very close plane distance (could be avoided with a different material/shader that disables ZTest for the canvas).

    If not, could this maybe be a bug with the Background Renderer, which as I have seen uses a Commandbuffer with a Blit of the camera texture at a specific render pass?

    If it isn't a bug, how do I set up the Background Renderer such that it works with 'Screen Space Camera' Canvases that are showed on top of the Camera Background?
    I'm open for a LWRP solution, as it seems less hacky and more modern (although we have to change completely to LWRP in our project then, which is planned anyway in the near future).

    I have also noticed, that if I don't have an 'AR Camera Background' Component at all, that it is not possible to raycast the Trackable Plane (which is displayed though, tried it with the LWRP Sample of the arfoundation samples), is this a bug as well?
    My idea was to render the camera texture into a separate 'Screen Space Camera' Canvas with a RawImage instead of using the AR Camera Background (don't know if this is a good/clean/fast solution though).
     
  2. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    792
    Easiest way to do this would be to use a separate camera.
     
  3. artfabrik

    artfabrik

    Joined:
    Jun 6, 2018
    Posts:
    4
    Ok, thanks for the answer, I've solved it now with multiple Cameras because there was a reason anyway to use multiple Cameras.

    But still, I think, as it is called 'AR Camera Background' it should be a background and not in front of Screen Space Camera Canvases. Should this be tracked as a bug/issue?
     
  4. imaginethepoet

    imaginethepoet

    Joined:
    Aug 23, 2016
    Posts:
    38
    I spent all night staring at this. Is this the reason my simple screen space UI won't render when I call it. This does seem like a big omittance and doesn't seem natural that I would need another camera. And if this is the case, how come when I leave the item on to start with it shows up as part of the canvas background correcly. @jimmya - Im experiencing this in latest Arfoundation github.