Search Unity

[New] Lighting Scenario Switcher - dynamically change lightmaps and scene lighting

Discussion in 'Editor & General Support' started by CloudyVR, Sep 13, 2017.

  1. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    For the past week I have been developing a tool for dynamically changing the lightmaps in my scene at runtime. The core scripts used for handling the lightmaps and light probes were originally sourced from Laurenth's example on GitHub which do a great job of keeping things orderly. Please note that this tool is still in a very early stage development - all feedback or assistance in finding bugs would be greatly appreciated!

    NOTE: Static Batching - I found that if I enable Project Settings>Player>Static Batching then the lightmap takes on different offsets at runtime causing misalignment. I have disabled static batching in my project, If I figure out how to compensate for the batch offsets I will update the example with a fix.

    Lighting Scenario Switcher on GitHub

     
    ShortE, Balours, Teosis and 1 other person like this.
  2. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
    Hi, how can I load the scenarios from AssetBundles after downloading them?
     
  3. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715

    After downloading the zipped file, copy it's contents to the assets folder:


    1. Load one of the example scenes (i'm using "Example_Detailed" in this image).
    2. Locate the LSS controller and click it to focus.
    3. There are 3 pre-saved lighting scenarios for Example_Detailed (found in Resources directory). You will have to enter the name of one of them to load:
    Example_Lights_Light
    Example_Lights_Dark
    Example_Lights_Alarm


    4. Load the scenario by clicking "Load Lighting Scenario"

    Because the project was just created, ensure that Static Batching is disabled!
    Goto: Edit>Project Settings>Player>Other Settings then uncheck Static Batching
     
    Last edited: Nov 13, 2017
  4. Teosis

    Teosis

    Joined:
    Jan 24, 2018
    Posts:
    22
    Really great tool, thank you for sharing it! One question though: does it handle the Environment (ambient) Lighting as well? I'm struggling with it atm; I'm trying to bake the Night lightmap and then the Day one and it is seemingly doing everything right, but when I switch from one Lighting Scenario (Day) to the next one (Night) the terrain would preserve the values of the last bake (the Day, for example). (The same issue goes for Laurenth solution)
    The directional light is off, the scene is illuminated with Evironment Lighting only (which, in turn, is controlled by skybox material exposure).
    I've added the skybox material to the correlated material node and its exposure value would adjust accordingly but the terrain (static) and a couple of other (non-static) objects just refuse to update upon the scenario switch.
    (Basically, the only thing which update itself are the trees placed via terrain tool and the skybox which is added to the material node)
    Static Batching is off.
    I think I'm doing something wrong.
    Can you help me with that?
    (Unity version 2017.3.0f3 )
    _
    P.s. I've tried to load one of the examples and it says that Lighting data asset is incompatible with the current Unity version; could it be the case? Damn, I hope it is not the case, coz the tool is otherwise so perfectly suitable and handy!
     
  5. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
    I experienced the same problem- day scene with ambient light, night scene with skybox material- and had the same issues. Solved it by cleaning the GI cache after each bake-store procedure. You can try cache cleaning by Unity->Preferences->GI Cache->Clean before and after baking and storing your lightmaps. Hope it helps.
     
    CloudyVR and Teosis like this.
  6. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello ;) Does it alaso work for realtime GI ?
     
  7. unitylepi

    unitylepi

    Joined:
    May 21, 2018
    Posts:
    34
    Pretty interested to know what we need to assigned any loaded reflection probes to. Reflection probes don't seem to go in the LightmapSettings or LightmapData :( The Unity manual only seems to talk about using them in the editor, not assigning them programatically. Anybody any ideas?
     
  8. ioesten

    ioesten

    Joined:
    Feb 19, 2018
    Posts:
    14
    Are there any plans to update this for Unity2019.3? sadly none of the examples work in 2019.3 version and hard to know how to fix..
    Am sure update would be much appreciated by many.
    Thank you!
     
    sacb0y, Plaximo and CloudyVR like this.