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

Lightmapping.BakeMultipleScenes (how to use)

Discussion in 'Global Illumination' started by TodorFine, Sep 29, 2015.

  1. TodorFine

    TodorFine

    Joined:
    Sep 28, 2015
    Posts:
    4
    Hi,

    I'm interested in the possibility to bake and merge together several scenes, which should be possible with Lightmapping.BakeMultipleScenes but I can't quite figure out how to use it. What would the standard workflow be?

    While researching I also came across Lightmapping.BakeMultipleLevel ... what's the difference between the two?
    Thank you for reading, any help is appreciated :)
     
  2. TodorFine

    TodorFine

    Joined:
    Sep 28, 2015
    Posts:
    4
    So I've been doing more experiments, trying to figure out the BakeMultipleScenes...
    Here is what I did:
    I prepared several scenes consisting of simple objects.
    001_Preparation.jpg

    Then I baked them with Lightmapping.BakeMultipleScenes and got a "LightmapSnapshot" as a result which I applied in "Scene main". Finally I combined the scenes together using "Application.LoadLevelAdditive"
    I get this scene with a "LightmapSnapshot" as shown below:
    002_Result.jpg
    As you can see each object's GI etc doesn't seem to affect the other objects.

    I tried putting all objects together and bake them the normal way and the result is different:
    003_example.jpg


    Any ideas? I am doing something wrong or am I expecting BakeMultipleScenes to do something it's not meant to do...?
     
  3. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    That should work fine both for Realtime and Baked GI. Just tried it myself:
    Baked.PNG Realtime.PNG

    Code used attached.
     

    Attached Files:

    bmouret likes this.
  4. TodorFine

    TodorFine

    Joined:
    Sep 28, 2015
    Posts:
    4
    Nice, that worked! Thanks a bunch, SpiriTx!

    One thing I'm not quite sure is what GI settings are used to bake each scene. Is it the current scene settings (the one from which I start the multi scene bake) or the settings saved in each individual scene?
     
  5. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    It uses settings from one scene. In this case it's settings from the first scene in array "paths".
     
    bmouret and Meltdown like this.
  6. TodorFine

    TodorFine

    Joined:
    Sep 28, 2015
    Posts:
    4
    Got it, thanks! That was very helpful! :)
     
  7. Johny_G

    Johny_G

    Joined:
    Mar 28, 2014
    Posts:
    20
    Is it possible to do such thing for multiple standalone scenes, which shouldn't be additively loaded? We would love to have the option to bake the maps for all levels through weekend. Thanks!
     
  8. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    Why not simply automate scene opening and baking lightmaps for that scene using editor scripts?
     
  9. Johny_G

    Johny_G

    Joined:
    Mar 28, 2014
    Posts:
    20
    Oh, how stupid am I? :)) Thanks a lot, the crunch time is messing with my mind.