Search Unity

Loading scene additively causes change in lighting

Discussion in 'Global Illumination' started by trzy, Jan 7, 2018.

  1. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    I load a scene additively and have my main camera in the first "core" scene and the game world plus single parallel light in the second scene (I've also tried retaining the light in the first scene). The game world now appears to be rendered at 50% brightness.

    I've read elsewhere on the forums that this could be a problem with global illumination not being re-computed. But I can't see any way to fix this in the Lighting window. Has anyone encountered this?
     
    filip-mixedworld likes this.
  2. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Screenshots of the problem shown. The brighter scene is how it looks when I load the scene by itself and throw in a camera. The darker scene is using additive loading with the main camera in the other, top-level scene.
     

    Attached Files:

    • 2.png
      2.png
      File size:
      220.2 KB
      Views:
      5,626
    • 1.png
      1.png
      File size:
      270 KB
      Views:
      5,194
    dan_ginovker likes this.
  3. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Ok, so when I had opened the Lighting window, the game was running. D'oh! Here is what I did to fix it (but I hope someone can clarify what is going on):

    1. Open the scene that is being loaded, containing the game world.
    2. Window -> Lighting -> Settings
    3. At the very bottom, uncheck "Auto Generate" and then click "Generate Lighting".
    4. Save the scene (leaving "Auto Generate" unchecked).

    "Auto Generate" is supposed to respond to any lighting changes in the scene. I guess this is a bug? Also, when I re-enable Auto Generate, it breaks again. Shouldn't it have saved the information from the last manual run? Is there some sort of internal cached light map that doesn't get flushed out?
     
    Magn077p, mahu, Tsuame and 17 others like this.
  4. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Hey trzy,

    couple ideas you could try, if none pan out file a bug for us to take a closer look and investigate your project.

    1) Try clearing the GI cache under Preferences
    2) When you select to generate the Lightmap, make sure the maps fully finished before entering play mode. You might see some weird behavior if you enter play mode before they're completely updated. There is a progress indicator in the right corner of the editor.

    This doesn't sound an XR specific issue so if these don't solve it, I'll go ask around the lighting team and see what we can find out for you.
     
  5. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Thanks for the reply. I've since encountered this problem again but now it's even more difficult to solve. My top-level scene contains a directional light. I load an empty scene (no camera, no lights, nothing at all) additively. The reason I do this is so that game objects all get created in this scene allowing me to blow it away when I want to return to the main menu.

    There are no lightmaps to generate here. All in-game objects are generated dynamically (this is a HoloLens app). Yet the lighting is screwed up for all objects in this new, initially-empty scene.

    Any ideas on what I can try?

    EDIT: If I remove the directional light from the main, top-level scene and add it to the loaded scene (so that now, this scene contains one game object initially -- the light -- before the others are created), it looks fine in the Unity Editor when playing.

    I can probably live with this for now but it's not ideal. My top-level scene will have a 3D menu that will need to be illuminated. I could turn that into its own scene but it's not really necessary and I would prefer that the light object resides there.

    I would also be very curious to better understand what's going on.
     
    Last edited: Feb 8, 2018
  6. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Go ahead and file a new bug for us so we can look at your project. We will try to reproduce it here and see if we can offer a workaround or take it as a bug to get fixed. Have it set up the way you want it to work, in your edit it sounds like you did some steps to try and work around it.
     
  7. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,728
    Im still seeing this.. did this never get looked at?
     
    JasonCostanza likes this.
  8. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    File us a new bug. I never got one from the original poster, we will take a look. Drop the bug number in here once you file it and I'll get it looked at as soon as we can
     
  9. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,728
    OK, there is some special sauce to it, cos I made a weeny project to show you and it didnt do it, but on my actual game, it does.. its now 1.40am.. maybe not work on this more tonight, try again tomorrow

    its now 2.20am, and im uploading..

    I think part of the issue is if you make a scene to hold UI, you load it additive but its possibly because the lighting on that scene effects the current, but it doesnt reset when you unload either.

    Pls note i even changed the lighting on the UI scene to black black black, and.. it does the same so this does totally reproduce the issue.. as both scenes had black black black but adding the UI made the whole thing lighter forever

    Case
    1137412
     
    Last edited: Mar 16, 2019
    JasonCostanza likes this.
  10. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Can you confirm this project is supposed to be XR Enabled? From opening it, it appears to be not set to that. If it's not an XR project I will forward this to the appropriate team as I am part of the XR team. Just want to make sure we get the right people looking at this.
     
  11. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,728
    No, its not XR, it is a generic issue in unity all over :D
     
  12. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Excellent, I will actually forward this to another team and make sure. SOrry for the confusion, this is the Windows Mixed Reality section of the forum which I patrol. Happy to get your bug where it needs to go though!
     
  13. DavidLlewelyn

    DavidLlewelyn

    Unity Technologies

    Joined:
    Aug 14, 2012
    Posts:
    34
    Hi @trzy. Looking at your screenshot it appears that the difference in the brightness between the two Scenes is due to missing / lower ambient lighting. Ambient lighting is most commonly derived from the skybox, although it is also possible to provide a gradient or flat colour. This is defined in (Window > Lighting Settings > Environment Lighting).

    It is only possible to display one skybox at a time. When additively loading Scenes together in a multi-Scene configuration, Unity must therefore apply some scheme to determine which skybox, from which Scene, is rendered. By extension this will also determine which skybox contributes to the ambient lighting used by all Scenes loaded in a given multi-Scene "constellation".

    Loading Scenes in a different order will change which is the Active Scene and therefore it may be that your settings (including skybox ) are being derived from a Scene different to that which which contains the bright skybox. The Active Scene can be changed via the Editor UI as show here:



    You can change the Active Scene via script using the SceneManager class from UnityEngine.SceneManagement: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html


    Further to this, I'm guessing you may be using Unity's default procedural skybox despite your Camera being set to clear to black. This skybox takes a Directional Light as a "sun" to determine how the sky should be rendered. If the skybox and the Directional light are in separate Scenes it may be the case that the sun is not active in the Scene when the skybox is rendered and lighting precomputed. This might be worth investigating.

    We've made an Additive Loading tutorial available on the Asset Store, which demonstrates some common Scene setups. The interactive UI contains text which explains everything in greater depth than I can here. It might be worth spending some time working through the tutorial which is available here: https://assetstore.unity.com/packages/templates/tutorials/additive-loading-lighting-examples-129922

    Cheers.
     
    Last edited: Mar 20, 2019
  14. sudogetpizza

    sudogetpizza

    Joined:
    Mar 13, 2019
    Posts:
    3
    I'm having the same problem as @trzy and I am making sure to change the newly added scene to be the active scene as you've described. I did however find that @trzy's original solution does work for me, though it is a bit cumbersome..
     
  15. radiatoryang

    radiatoryang

    Joined:
    Jul 7, 2014
    Posts:
    19
    Note to everyone else who gets here via Google: at least in Unity 2019.1.11f1, it's important to yield a frame between loading an additive scene before setting it active, otherwise it won't work (ambient lighting won't switch over)

    Code (CSharp):
    1. SceneManager.LoadScene( "myScene", LoadSceneMode.Additive );
    2. yield return 0; // wait a frame, so it can finish loading
    3. SceneManager.SetActiveScene( SceneManager.GetSceneByName( "myScene" ) );
     
  16. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    569
    I experience the same issue in 2018.3.4f1. I load a scene additively and its lighting is not activated. I tried your suggestion and it *appears* to fix the problem! Thank you!
     
  17. ilyasrussell

    ilyasrussell

    Joined:
    Jul 18, 2019
    Posts:
    1
    I solved mine by changing my main scene's light to "Baked" mode. Simply click on the Directional Light > Light > Mode, and switch it to "Baked", rather than "Mixed".

    Next step is to go to Window > Rendering > Lighting Setting, then unchecked the "Auto Generate" and click "Generate Lighting".
     
    truthmiles and jussikuosa_unity like this.
  18. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    Switching the active scene is not a solution for us. In a multiplayer game, the server and client have a common main "container" scene, and both additively load subscenes for the various levels. Each level has different skybox, lighting, etc. The container scene has no lights, no skybox, just a main camera set as shown below.

    upload_2020-4-3_16-21-43.png
     
  19. NarryG

    NarryG

    Joined:
    Mar 11, 2020
    Posts:
    10
    Did you ever find a solution to this?


    Edit: -----

    Note to anyone having this issue: In addition to the main scene needing a lightmap baked, all lightmaps also need to be baked as directional or non-directional. It will not properly load a directional lightmap if your active scene uses non-directional lightmaps
     
    Last edited: Nov 3, 2020
    jeromeWork likes this.
  20. Keepps65

    Keepps65

    Joined:
    Oct 26, 2017
    Posts:
    4
    That did the trick for me. Thanks!
     
  21. springloaded_software

    springloaded_software

    Joined:
    Nov 24, 2015
    Posts:
    12
    did you ever find a fix for this? I am so close to locking down my first playable demo, and this issue has stopped me in my tracks....3 months of work, and now I am stuck.
     
    PrabhakaranRajendran likes this.
  22. springloaded_software

    springloaded_software

    Joined:
    Nov 24, 2015
    Posts:
    12
    I am using HDRP, and this doesn't appear to work, the tutorial on the asset store is also broken. (Ideally I wouldn't switch active scene, but even doing that via the editor, or code doesn't work). Additive scene loading is how Unreal is used, so I just jumped into unity thinking I could use the same approach.
     
    PrabhakaranRajendran likes this.
  23. o2co2

    o2co2

    Joined:
    Aug 9, 2017
    Posts:
    45
    SceneManager.SetActiveScene( SceneManager.GetSceneByName( "myScene" ) );

    You can solve the problem in the URP, thank you
     
    Atto2O and Chusuk like this.
  24. Katnut

    Katnut

    Joined:
    Oct 8, 2020
    Posts:
    1
    I'm a newbie and none of the advice helped me. However when I went to Window > Rendering > Lightning > scene tab; If "lightning setting" says “none”, click on it and choose “demo”- setting. Press “generate”.
    So it seems like it was missing settings all together which made the scene go dark when loaded. Hope this helps.
     
    bodhi_berry likes this.
  25. PrabhakaranRajendran

    PrabhakaranRajendran

    Joined:
    Sep 21, 2017
    Posts:
    5
    really frustrating, adding a sample scene with a Cube add a script call SceneManager.LoadScene(0); issue appears. Using unity 2020.3.4 LTS (URP template)
    I have only one scene on restart issue appears none of the solutions above mentioned worked for me

    SceneManager.SetActiveScene( SceneManager.GetSceneByName( "myScene" ) ); - setting this didnt reset the scene :(
     
  26. sachinbirajdar

    sachinbirajdar

    Joined:
    Feb 23, 2017
    Posts:
    11
    In unity 2020, if you are facing this issue then click on Generate Lightning. It should work.
     
  27. PrabhakaranRajendran

    PrabhakaranRajendran

    Joined:
    Sep 21, 2017
    Posts:
    5
    This means that i need to use the baked lighting, and this happens only with in editor not in the application built out of it.
     
  28. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,661
    i love your profile pic xD
     
  29. gchetan15294

    gchetan15294

    Joined:
    Jul 7, 2021
    Posts:
    2
    This Helped Thanks
     
    bodhi_berry, rbhsk and grjensen like this.
  30. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    Your asset has been deprecated, and I can not access it. Could you provide it again, please?
    Or is it outdated? Thank you very much!
     
  31. Chusuk

    Chusuk

    Joined:
    Apr 19, 2021
    Posts:
    43
    Lots of hours trying to resolve some strange lighting...only to find this line was missing from my code!

    Some phrases for search engines....

    Black Shadows not reacting to lighting settings.
    Real time shadows not acting as expected.
    Crest Ocean shadows on water not working.
    Skybox shadows too dark.
     
    Atto2O likes this.
  32. yektasarioglu

    yektasarioglu

    Joined:
    Dec 29, 2018
    Posts:
    3
    This bug persists in 2020.3.7f1. I hope, they fixed it in the recent versions.
     
    tokar_dev likes this.
  33. Charles_Games

    Charles_Games

    Joined:
    Jun 2, 2020
    Posts:
    1
    ☝️ This bug persists 2020.3.21f1
     
  34. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    320
    If you are still experiencing this and it is blocking you, I suggest filing a bug report. As far as I can tell, we never got one from OP, and the one case that was reported (case 1137412) was addressed in David's earlier message.

    Also gonna drop a link to this post for those googling for answers since it is tangentially related:
    [Solved] SceneManager.LoadScene() make the scene darker... a bug? - Unity Forum
     
  35. salamlex147

    salamlex147

    Joined:
    Dec 23, 2021
    Posts:
    1
    This helped me a lot :D tysm
     
  36. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    Setting the active scene worked for me (fixed lighting and got the fog showing again).

    I am loading scenes additively to work around a nasty bug in Entities 0.50 with prefabs and companion objects.
     
  37. Bmco

    Bmco

    Joined:
    Mar 11, 2020
    Posts:
    54
    I had a similar problem, but the Rendering/Lighting Window is very deceptive about which Scene you're changing the settings on. I had a Main Start Up Scene that I was accidentally setting all the light options for. When I changed the active scene to a level scene, I lost my Skybox. If you're going to change Lighting Settings, make sure all other scenes are unloaded.

    Ideally, the Rendering/Lighting Window would have a dropdown displaying the Scene you're changing the properties for.
     
    socialtrens, spacefrog and LilGames like this.
  38. Ell223

    Ell223

    Joined:
    Jan 27, 2014
    Posts:
    15
    Running into this in 2021.3.2f1, but only in a build. All of my scenes have the exact same environmental lighting, no skyboxes, and only one scene has a directional light- which is realtime. I'm setting that scene as the active scene. Have generated lighting in all scenes.

    Can't reproduce it in the editor, so it's making it quite difficult to figure out.

    The problem seems to be, for whatever reason, the build is changing the environment lighting value. I wrote a quick script which just sets RenderSettings.ambientLight to the correct value in Update, but even that doesn't seem to effect anything in the build- works perfectly fine in the editor. All the scenes I am loading have the exact same lighting values/colours etc.
     
    Last edited: Jun 19, 2022
    IgorBoyko likes this.
  39. Crzed

    Crzed

    Joined:
    Oct 19, 2013
    Posts:
    27
    Hitting this issue as well, 2021.3.5f1

    The listed solutions don't appear to be working. Default camera skybox, default directional lighting.

    I modified things so there's only a single directional light in the second scene, with no light in the starting scene, but there's no change. I still see the same behavior shown in the OP's screenshots.

    Further edit: it appears to happen in the editor only, if I build and run it, I don't see the issue.
    Is definitely skybox related. Modifying lighting->environment to use 'color' instead of skybox for the source means there's no longer a change in lighting on loads.
     
    Last edited: Jul 10, 2022
  40. adamoverstreet20

    adamoverstreet20

    Joined:
    Jan 4, 2021
    Posts:
    4
    Gonna take it as this was not fixed? i read everything that was said to fix this issue, done everything
    my only solution is to delete both cam and light from my 2 scenes and replace them, i cant do that while playing the build product if this is still happening its clearly a bug that needs fixing please
     
  41. YourSunshine

    YourSunshine

    Joined:
    May 16, 2019
    Posts:
    1
    Hey there :)

    I had a similar problem;

    I have 2 scenes in my project (main menu and the actual game).
    Whenever I loaded the game-scene from the main menu the lighting was getting an orange touch. I played arround with the lighting settings a bit, but nothing helped so I ended up setting them back to default.

    I have 2 directional lights set up (one in each scene), I noticed that the one on the main menu had a different rotation from the one in the game-scene.

    I changed the rotation on each light back to the default rotation, which did the trick for me.
    (In my game there is no need for the light to come in different directions, so that's pretty neat^^)

    I tried to reverse engeneer it (in case I clicked something and didn't realise it), but as soon as i changed the rotation on one light the orange glow was back, so I guess this could be the problem.

    Hopefully this helps someone.

    Much love <3
    bb.
     
  42. tolgakaranlik

    tolgakaranlik

    Joined:
    Oct 8, 2020
    Posts:
    7
    worked for me, thanks!
     
  43. tlsharkey

    tlsharkey

    Joined:
    Jul 27, 2018
    Posts:
    2
  44. maikkanerva

    maikkanerva

    Joined:
    Dec 14, 2018
    Posts:
    27
    I had this issue also.
    I was using a system where I load in a loading screen scene, unload the current scene and load the next (requested) scene.

    When the loaded scene became active in play mode, the lights would first be darker for a few frames and then be normal.

    The solution for me was to set the active scene to be the loaded scene.
     
  45. totalwork

    totalwork

    Joined:
    Mar 19, 2024
    Posts:
    1
    Whenever I try to click or change any of the settings in the scene which is located in lightning nothing I can change there,I can only change the lighting setting asset.and I can't even change intensity


    Kindly give a solution for it



    Thanks in advance
     

    Attached Files:

  46. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    320
    Lighting settings for the scene are stored exclusively in lighting settings assets. Your scene doesn't have one assigned. Press the "New" button to create a new one and assign it to the scene, then you should be able to edit the settings.

    If you are looking for settings specifically related to environment lighting, those live in the Environment tab near the top of the lighting window.