Search Unity

Baked lighting (static object) in an AR Scene

Discussion in 'AR' started by rob_ice, Oct 23, 2018.

  1. rob_ice

    rob_ice

    Joined:
    Nov 11, 2016
    Posts:
    112
    From a great example video posted by @djayboy007007 , I noticed someone figured out how to place a static (baked lighting) object in an AR scene - how is this do-able?



    I have always had the issue of the object needing to be marked as static which means it is not able to be placed or moved (obviously) in AR - any tips?
     
  2. djayboy007007

    djayboy007007

    Joined:
    Mar 14, 2015
    Posts:
    5
    Marko325 likes this.
  3. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Is this a problem if you are using the MakeContentAppearAt and moving the session origin? ie. you are not moving your static objects, but moving the AR Session Origin instead?
     
  4. rob_ice

    rob_ice

    Joined:
    Nov 11, 2016
    Posts:
    112
  5. dyuldashev

    dyuldashev

    Joined:
    Mar 3, 2016
    Posts:
    76
    If you guys are struggling to use baked Game Objects, it's straightforward. Just change the placement script to set inactive game objects as active instead of placing prefabs. In the Update() function, when you instantiate a game object, you just activate your game object, and that's it.
     
    rob_ice likes this.
  6. MSQTobi

    MSQTobi

    Joined:
    Feb 12, 2018
    Posts:
    8
    You can set your content as non static and tick only static "Lighting static" options in the dropdown. This way you can bake lighting and still move the object. If you rotate you object relative to your light source then the lighting will obviously not update and be wrong.
    Also note that static batching will not work with this approach.

    We had a project where we wanted to move a complete scene inside our AR application (animated)
    The main problem with the above approach is, that static batching will not work. This had an unbearable performance impact in our case. Our solution was quite simple. Tick everything in the static dropdown except "Batching static".

    Place this script at the root object of the static object group:

    Code (CSharp):
    1. public class StaticMeshCombiner : MonoBehaviour
    2. {
    3.     private void Awake()
    4.     {
    5.         StaticBatchingUtility.Combine(gameObject);
    6.     }
    7. }
    8.  
    Now you can move the root object (not the chilrden) and static batching will still work.

    Hope this helps!

    Greetings
    MSQ Tobi