Search Unity

Question Is it possible to turn off occlusion for single objects in AR core?

Discussion in 'AR' started by joze05, Oct 15, 2021.

  1. joze05

    joze05

    Joined:
    Jun 24, 2019
    Posts:
    5
    Basically the title.
    Using AR core with depth API automatically occludes virtual objects, when they are 'behind' real world objects. Is it possible to either turn off this occlusion for single object, or altogether, while still using the depth API (I tried simply deactivating the AR Occlusion Manager, but this leaves me without depth data).
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,145
  3. joze05

    joze05

    Joined:
    Jun 24, 2019
    Posts:
    5
    @KirillKuzyk Thanks a bunch for the info and please excuse my very late reply. The given links helped a lot.

    For anyone having a similar problem, I ended up doing two things:
    Disabling and enabling the Occlusion Manager based on the situation. However, soon I came across the need to have the depth sensing, but turn off the occlusion. The given tips with the offsets didn't apply to my particular use case, since I'm using AR Core without a depth sensor, the mesh in question is from a reconstruction algorithm, which uses the depth data to reconstruct the RL scene. However due to the depth being not as accurate as it would be coming from a ToF sensor, this reconstructed mesh is a (good) approximation. I mostly use it for calculations in the background, but what caused the original question was, that I also wanted to use it for differential rendering to cast shadows onto RL objects.

    For this I ended up, copying the original ARCore Background shader and modify it according to my needs, which simply meant to remove the occlusion parts. With my reconstructed mesh being transparent, if I turn ZWrite on, I still get the occlusion for all other objects, but the (mostly invisible) reconstructed mesh is not affected.

    I guess differential rending is a common use case, so maybe ARCore lets one choose to turn off occlusion for particular objects in the future.
     
    KyryloKuzyk likes this.