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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Swapping LightmapSnapshot at runtime

Discussion in 'Global Illumination' started by mikamikem, Mar 23, 2015.

  1. mikamikem

    mikamikem

    Joined:
    Mar 3, 2013
    Posts:
    10
    Short question: How do I programmatically swap at runtime the LightmapSnapshot asset?

    Background:

    I'm working on a project that uses a set of scenes and hides or shows different objects based on what in-game day is being played. Since the objects that were being hidden or shown didn't move around, we marked them as lightmap static and were able to bake lighting in Unity 4 on those objects. We had a full build system set up to manually cache off the lightmap index, tiling, and offset values during bake time and re-populate those values at runtime after loading in the scene.

    From what I can tell from other forum posts, the LightmapSnapshot object contains all this information now (which is great), but the only method I can use to get to the current snapshot is by using reflection and serialized properties and I haven't found a way to assign the asset at runtime (not great). In editor I tried assigning the LightmapSnapshot after loading into the scene and it didn't seem to do anything, so I'm assuming this might be part of the level load stage, but it also seems like there should be a function I can call to load the snapshot.


    If anyone has any thoughts on how to swap this at runtime, I would greatly appreciate the help!
     
  2. insominx

    insominx

    Joined:
    Jan 23, 2012
    Posts:
    32
    From what I gather right now, you can't. I could really use this as well. My scenes / levels are just prefabs that I dynamically load based on what the player chose. However, there doesn't appear to be a way to save lightmaps outside of a scene. Ideally, when I load my prefab, I would set the lightmap snapshot that goes with it.
     
  3. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
  4. GreenRabbit

    GreenRabbit

    Joined:
    Nov 27, 2013
    Posts:
    4
    Lightmaps is one thing, but what about light probes? Switching lightmaps is useless without switching light probes as well...