Search Unity

ARFoundation - Make skybox visible and occlude camfeed

Discussion in 'AR' started by newguy123, Jan 11, 2019.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Hi all

    Strange question. I have a situation, where I need to switch between different modes in the ARScene. One where you have a typical AR scene where you see the real world in the cam and your placed prefab, the other, where the realworld is occluded by the skybox (ie the skybox is visible in frame).

    Is it possible to achive this? Only way I can currently think of achieving this, is have a very large sphere with a sky texture on it, covering my scene and AR Session and switch that on/off.

    Is there a way to just use the built in skybox in the lighting settings?
     
  2. MarcosFMAndrade

    MarcosFMAndrade

    Joined:
    Aug 3, 2018
    Posts:
    1

    This sounds a little bit weird but it worked for me. Basically what I did was:
    Duplicate the AR Camera;
    Change "Clear Flags" to Skybox on camera2
    Use the folowing code to switch between camera textures:

    public void switchCameras()
    {
    var tex = cam1.targetTexture;
    cam1.targetTexture = cam2.targetTexture;
    cam2.targetTexture = tex;
    }

    (This is the weird part)
    On Build Settings check "Development Build" and build
    Latter on you can uncheck it.

    Hope this helps :)
     
  3. AmshuRak

    AmshuRak

    Joined:
    Jun 25, 2018
    Posts:
    3
    I had a similar problem, where I was trying to make a portal. I wanted my camera feed to display outside the portal and when the user entered inside the portal I wanted the background to switch to the skybox.

    I was able to do this with the help of this amazing youtuber's tutorial:


    If confused have a look at his series on making Portals, it wont take long and its worth it.
     
    MarcSpraragen likes this.
  4. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Hey @AmshuRak how did you manage with this?

    Did you manage to convert stuff to AR Foundation?

    Seems his examples is specific to either ARCore or ARKit, but I'm using AR Foundation...
     
    Sprarage likes this.
  5. Sprarage

    Sprarage

    Joined:
    Aug 1, 2013
    Posts:
    7
    Hi, same problem here, using Unity 2019.3.0f3 and ARFoundation 3.1.3. The Pirates tutorial works with the non-AR device but using AR foundation causes the portal to stop working (scene disappears when passing through portal). From what I have read, it has something to do with the AR rendering (and lighting?) queue order vs. the various materials, and/or the AR camera depth vs. skybox camera. Still trying to get it to work. I'm also trying this tutorial, not perfect success but some stuff works.
    https://yuuuuu.net/2018/02/08/augmented-reality-portal-based-on-arfoundation-in-unity/#020201