Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Realtime GI + LoadLevelAdditive

Discussion in 'Global Illumination' started by Aberdyne, Nov 20, 2015.

  1. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Hello everyone.
    A little bit of context first. In this post, 1) talks about baking realtime gi in separate scenes. 2) seems to be implemented as of version 5.2.2f1 (the version we're using right now). Extrapolating from this thread 1) should be implemented too, right?

    What we're doing right now for our current project is to load several scenes additively at the same location and deactivate all but one to show only one variation of the same room. The very first scene which is empty act as a container and has Realtime GI activated with a single directional light. Whenever I load the other scenes additively, the first scene (which is baked separately like all others) show up correctly but others are completely black and I see those error messages in the console:

    ErrorGILoadLevelAdditive.png

    @SirKruc in this post seems to describe the same result, the entire thread in itself doesn't talk about the other two errors though.
     
    Last edited: Nov 20, 2015
  2. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    I made some additional tests.
    • clearing the cache and rebake the other scenes ---> same problem
    • ticking the auto checkbox in the lighting panel for additively loaded scenes (proposed solution from the previous thread I mentionned above) ---> 1st scene loaded additively is okay (as before), others are no longer black but have no GI (?!)
    • making sure the container scene has auto ticked too --> idem
     
    Last edited: Nov 20, 2015
  3. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    So... nobody have the same problem???

    We could find a workaround for our use case. Since first additively loaded scene seems to load with GI working, it's very simple. Make sure Auto is disabled then bake all rooms together in the same scene by separating them enough from each other (100 units for us), then put them back to their original location after baking and finally save. Load additively only this unique scene. This only works of course if you don't have any problem loading all rooms at once... otherwise you'll hit the same problem again as additional load additive on other scenes will break GI for those.
     
  4. plailabs-dev

    plailabs-dev

    Joined:
    Dec 10, 2012
    Posts:
    12
    Hello. I have the same issue but I´m using asset bundles. We are trying to figure how to have the precomputed realtime light maps embedded in the asset bundle. Any pointers?
     

    Attached Files:

  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I would have to test this myself, but... setting lightmap snapshots via script?
     
  6. plailabs-dev

    plailabs-dev

    Joined:
    Dec 10, 2012
    Posts:
    12
    FuzzyQuills, I have not seen an API to set Realtime light map snapshots, but only baked light maps.
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, chances are that it isn't possible, but I'll look around in the docs and see what I can find.

    EDIT: Damn... I found something that could help, but it's limited; the Lightmapping class can have a LightmapSnapshot set, but it will only take effect when loading the scene. Perhaps one could patch the lighting in while loading? ;) (If it's possible, I could always test this for everyone if needed)
     
  8. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ok, so the LightmapSnapshot is currently editor-only, so that's out. (@brainz12345, you're right in saying there's no realtime option yet, I just did my research... :D)

    However, because the lightmapSnapshot's mostly a set of pointers to various pieces of data, (Except light probes, I think they're stored in the snapshot) it's likely possible to just pull out the baked maps from the folder with the scene name on it, and stick it somewhere else. (Say, for asset bundles. ;))

    If it's a directional lightmap, there will be two maps, one with the lighting, and one with light direction information.

    As for loading the maps, one would have to manually move the UVs around in the 3D modelling app, then bake with those, that way, you don't need to worry about Unity's lightmap scaling/offsets breaking stuff. ;)
     
  9. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    What method do you use for loading your scene additively?

    We load a buch of scenes additively and so far haven't encountered the issue. We use the new SceneManager to load and here's our workflow:
    • Editor: We bake our main scene (a giant snowfield) GI.
    • Editor: We bake all individual scenes (not additively loaded in the editor)
    • Runtime: We use SceneManager.LoadSceneAsync (name, LoadSceneMode.Additive)
    If you use the old method of loading scenes, you might run into some issues.

    Here's my test script:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class LoadScene : MonoBehaviour
    6. {
    7.     [SerializeField] string sceneName = "SceneName";
    8.     bool isLoaded = false;
    9.  
    10.     void Update ()
    11.     {
    12.         if (Input.GetKeyDown (KeyCode.L))
    13.         {
    14.             if (!isLoaded)    StartCoroutine(Load (sceneName));
    15.             else             Unload (sceneName);
    16.         }
    17.     }
    18.  
    19.     IEnumerator Load (string name)
    20.     {
    21.         AsyncOperation async = SceneManager.LoadSceneAsync (name, LoadSceneMode.Additive);
    22.         yield return async;
    23.         isLoaded = true;
    24.     }
    25.  
    26.     void Unload (string name)
    27.     {
    28.         SceneManager.UnloadScene (name);
    29.         isLoaded = false;
    30.     }
    31. }
     
  10. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    The SceneManager came with 5.3 right? Unity5.2.2f1, which we were using at the time of my first post, didn't. Thanks for the info though, I'll know what to look for the next time I need GI for a project.
     
  11. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    For the record, in Unity5.2.2f1, you would have to bake your scenes GI via an editor script using the Lightmapping.BakeMultipleScenes method.
     
  12. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Yes true forgot about that one. I've seen that too late... I still wonder if it would have worked with our use case...
     
  13. variablestatekieran

    variablestatekieran

    Joined:
    Jun 12, 2015
    Posts:
    26