Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

ARFoundation - Make skybox visible and occlude camfeed

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

  1. newguy123


    Aug 22, 2018
    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


    Aug 3, 2018

    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


    Jun 25, 2018
    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


    Aug 22, 2018
    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


    Aug 1, 2013
    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.