Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[RELEASED] Magic Lightmap Switcher - Storing, Switching and Blending Lightmaps in Real-Time

Discussion in 'Assets and Asset Store' started by Eugene-B, Apr 7, 2021.

  1. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    I have not seen this behavior before. Can you connect to the Discord server for a more detailed investigation of the problem?
     
  2. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    By the way, about broken lightmaps. The documentation in the Bakery section has a description of the detailed problem. Try it, it might help.

    Bakery uses its own lightmap array and tries to load it at runtime during edit playback. If you baked a scene using the Bakery, and then for some reason decided to use the built-in lightmapper, then you need to clear the scene data. Otherwise it will break lightmaps. Use Bakery ➞ Utilites ➞ Clear Baked Data
     
  3. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    It turns out that this happens with the Simple Lit Shader.

    However, there are other problems when generating the lightmap.
    First, create a new project and import Bakery, Magic Light probe, and Magic Light Switcher.
    At this stage, it's working fine, but if you play with the material shader used for QuickStart as SimpleLit, the lightmap will be destroyed.
    Furthermore, since I am making games for Quest and PCVR, I import Oculus Integration, XR Plugin, Oculus XR plugin, SteamVR Plugin, and develop with Android as the development environment and ASTC as Texture Compression.
    (Problems also occur in PC, Mac & Linux Standalone mode)
    It seems that Magic Light Switcher is not able to generate a lightmap correctly in the process so far.
    All sorts of bugs have occurred, but the light probe and reflection probe are not generated, and multiple lightmap textures are generated directly under the asset folder.
    This is a phenomenon that was not possible when the lightmap was generated correctly.
     

    Attached Files:

    • 1.jpeg
      1.jpeg
      File size:
      171.1 KB
      Views:
      313
  4. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi! You seem to be a member of the Discord community? Let's continue our communication there, we will fix the problems in order.
     
  5. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    I've never used Discord so I don't know how to get support on Discord.
    Since I use machine translation, Discord has a high threshold in that respect as well.
     
  6. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    I also use machine translation in part. You just need to follow the link and join the community, and then write me a message. In any case, if it is not convenient for you, then we can try to do it on the forum.
    To begin with, I would be very grateful if you could record a video in which I could see at what point the problems arise and understand how I can repeat it on myself.
    You can also write step-by-step instructions on which I can move and get the same errors as yours.
    Another option is a remote connection via AnyDesk, I often use this option to diagnose and solve problems.
    This allows me to quickly and accurately identify the source of the problem, and sometimes solve it directly.
    Which option is more convenient for you?
     
  7. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    I may be taking the wrong steps in recreating the lightmap.
    The first BakeAndStoreLightmapsQueue worked correctly in the minimal project, but the lightmaps are not generated correctly after that.
    Could you please tell me the procedure to overwrite the lightmap data?
    Is the lightmap updated just by specifying an existing one in Scenario To Replace Data and pressing Bake And Store Lightmaps Queue?

    Also, what data should I delete if I want to start over?
     
  8. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    I'll start from the beginning.
    You have several options for working with an asset.

    1) You bake the lightmap as usual through the Unity Lighting window interface. When ready, you should switch to the MLS Manager window and click the Store Baked Lightmap button. This will be stored to the resources folder, and in the interface you will see a record that you have saved lightmaps. The same will happen if you press the Bake And Store button. This just brings up the baking and then automatically stores all the baked data.
    Once you have at least two lightmaps stored, you can create a scenario and add those lightmaps to it (actually, not just lightmaps, the object contains all the information about the scene). This will allow switching and blending between them. You can also have several scenarios for one scene and switch between them programmatically.
    2) The method described above is applicable when you are in Once mode, if you switch to Queue mode, you will be able to create presets, it works exactly the same as in the first option, but baking and storing is started several times for different presets. Here you can also check the Create Lighting Scenario option, this will automatically create a scenario and add all the stored lightmaps to it.

    To completely remove all data, you can use the Remove buttons for lightmaps and for a scenario. After deleting the saved data, clear the lightmaps through the Lighting window. This will give you a scene completely cleared of lightmaps.
     
  9. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    About updating the stored data.
    If you store a lightmap and the name of that lightmap is already in the stored data, it will be automatically overwritten.

    In Queue mode, this will also be done automatically. However, the data in the scenario is replaced only if you check it in the drop-down list. To manually replace the data, simply switch to the Switching / Blending tab and specify the lightmaps you need for the scenario using the standard Unity selection window.

    You also can completely remove all stored data via removing data folder. Its located in Resources folder.
     
  10. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    I want to draw your attention to the use of an asset in iOS and Mac. Don't try this, it's not ready yet, which is why iOS is not listed on supported platforms. I will study this question tomorrow.
     
    Dean-Kuai likes this.
  11. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    AntonioModer likes this.
  12. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Micro patch 0.94.1b for MLS Pro available in the store.

    Bug Fixes:‌
    • Fixed a bug due to which it was not possible to correctly create a System Properties asset.
    • Fixed a bug due to which the building of the project failed.
     
    AntonioModer likes this.
  13. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    @Eugene-B This is a neat asset, any plans to also add support for iOS?
     
  14. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    In general, it seems to work on iOS too. But I only have one user with this system. The main problem was that we could not patch the standard shaders due to the write access restrictions in the system folders. Otherwise, this should work, but I cannot say this, since this is too unexplored territory. I can include you in the beta testing program if you have a desire to dig deeper into this.
     
  15. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    92
    Hi there !
    I recently bought the asset and i ran into a little problem. I usually just copy the URP and CoreRP Package into a LocalPackages folder and reference it in the manifest file like this:
    "com.unity.render-pipelines.core": "file:../LocalPackages/com.unity.render-pipelines.core",
    "com.unity.render-pipelines.universal": "file:../LocalPackages/com.unity.render-pipelines.universal"
    I need to be able to easily edit the render pipeline contents, especially shader files.

    Is there a proper Way to make this kind of workflow work nicely with Magic Lightmap Swichter? I didnt do enough testing yet, but right after installation i got an out of bounds error in MLSShaderCodeModifier.cs so i just hacked it:
    Code (CSharp):
    1.         private static void GetInstalledSRPVersion()
    2.         {
    3.             if (!systemProperties.srpPatching)
    4.             {
    5.                 if (string.IsNullOrEmpty(systemProperties.srpVersion))
    6.                 {
    7.                     // systemProperties.srpVersion = Path.GetFullPath("Packages/com.unity.render-pipelines.core").Split(new char[] { '@' })[1];
    8.                     // HACK: Doesnt work because we use local packages
    9.                     systemProperties.srpVersion = "10.6.0";
    10.                 }
    11.             }
    But i see that there's more stuff going on then just requesting the version number and i'd like to know if that could cause trouble or if i should do local RP Packages differently?

    Best regards and thank you very much for such a lovely asset <3
    Unity would be nothing without the marketplace creators !
     
    Eugene-B likes this.
  16. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi!
    MLS does the same thing as you, it edits the SRP shader files and moves the packages to the Packages folder to make them local and prevent autorecovery. What you can do is save your edited packages separately, then install pure SRP packages, then patch the shaders, and then manually make your own changes. This should do the trick.
     
    Last edited: Sep 19, 2021
    DonCornholio likes this.
  17. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    @Grumpy-Dot
    About the SRP version error. If you have version 0.91b then update the plugin, as the new update fixes this error.
     
  18. AntonioModer

    AntonioModer

    Joined:
    Jul 29, 2014
    Posts:
    65
    @Eugene-B , hi
    it posible make local baked lightmap (from light source) blending with global lightmap, to simple turn on/off light source ?
    it like fake realtime Global illumination
     
  19. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Yes, if I understand you correctly, then you just need to bake two lightmaps. global with local light on and global with local light off
     
    AntonioModer likes this.
  20. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    MLS Pro: Update 0.94.4b is available in the store (SRP 12+ support)
     
    Inspeinre likes this.
  21. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    134
    Hey there.

    Just a little confused, my 2 preset test its baking the lightmaps correctly as I reviewed the pngs, but loading the first one doesn't seem to swap

    result of loading new_preset_1

    upload_2021-11-16_17-2-55.png

    I later tried baking 3 presets. the last 2 worked (swapped in editor), it always seems to be the first one that wont load.

    Latest version on URP Unity 2021.1.11
     

    Attached Files:

  22. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Are you making new baking and the first preset always doesn't work correctly? Check the preset settings, maybe you accidentally changed Indirect Intesity or some other parameter of the light source, also pay attention to the Environment Settings tab in the presets. There may be 0 in the intensity from the sky.
     
  23. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    134

    Yes, this is a new scene to trouble shoot this problem, as it was also happening in the quick start scene.


    The first preset (preset 1) lightmaps aren't swapping to the baked one, preset 1 is using the same lightmaps as preset 2

    preset 1 result
    upload_2021-11-17_14-14-57.png

    preset 2 result
    upload_2021-11-17_14-15-30.png

    You can see the assets are created but are not being used in when loading the first preset
    upload_2021-11-17_14-34-24.png
     
  24. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Ok, I'll check it out. By the way, Reflections Blending Range and Lightmaps Blending Range are fully clamped, which means that you will always have a second lightmap displayed. Stretch the ranges fully and see if it works.
     
  25. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    134
    Seems like that was it, a bit random behavior states for the range sliders on new and old scene implementation, maybe look into that. By the way, you're a god damn legend for making this tool, been begging my lazy team to do this for years.

    Cheers! Looking forward to smashing in that 5 star review.
     
    Eugene-B likes this.
  26. AuriMoogle

    AuriMoogle

    Joined:
    Jun 4, 2018
    Posts:
    15
    Does it work with static batching?
     
  27. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Yes.
     
  28. AuriMoogle

    AuriMoogle

    Joined:
    Jun 4, 2018
    Posts:
    15
    How? It's spamming warnings and exceptions in the example scene. upload_2021-11-22_16-59-53.png
     
  29. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    This is only in editor mode as I am using PropertyBlock to avoid instantiating material in the editor. In play mode and in build, instances are created and material properties are set directly. This saves Batcher. You can check this through the frame debugger or through the Stats window.

    By the way, about the exception, show me in more detail what is there.
    Which line?
     
  30. AuriMoogle

    AuriMoogle

    Joined:
    Jun 4, 2018
    Posts:
    15
    I also encountered warnings/exceptions when building to device (Android). We are currently using the SRP batcher for our scenes, which does not support material property blocks.

    Detailed exception:
    upload_2021-11-23_14-25-45.png

    In the meantime, we implemented a custom solution for our special use case but thanks for your support.

    Side note: Your plugin is not moveable to a different folder than Assets/ because of hardcoded paths. It would be great if you could fix this for future users.
     
    Last edited: Nov 23, 2021
  31. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Actually, I provided for this and it should have moved without problems. I'll check it out, thanks!
    As I said, Property Block is not used in play mode or build. Variables are set directly via material.SetVar(). I'll check it out as well.

    About error:
    upload_2021-11-23_18-57-31.png

    Will be fixed in the next update. Thanks!
     
  32. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Magic Lightmap Switcher (Pro) updated to release version 1.0.0.

    Bug Fixes:

    • Lighting Scenario: Fixed Events serialization errors.
    Improvements:
    • Core: Bakery RNM + SH for SRP added.
    • Core: Added support for Bakery Shader Tweaks.
    • Core: Added support for Deferred mode in HDRP.
     
  33. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    88
    Is it possible to use this to solely switch between sets of light probes?
     
  34. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    It depends on what you mean by the set. It is not possible to replace the number and positions of probes at runtime, but it is possible to replace data within the probes. This is what MLS does
     
  35. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    398
    Hi,

    I have just bought and imported the Magic Lightmap Switcher (Pro) into:

    - Unity 2020.3.22f1
    - URP
    - Using Bakery

    I tried following the Quick Start and also Importing the 'Barkery' and 'URP' packages but end up with:



    It looks like the Bakery/URPDirSpec was changed or became corrupted by the 'Bakery' import package from Magic Lightmap Switcher. As for the errors, I have no idea but it was when I tried to create a Preset as stated in the docs.
     
  36. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    398
    Ok I see part of the issue:



    I already had "Magic Light Probes" and arranged my scene so the 'Magic Tools' GameObject was put in a folder in my scene:



    I have to say it seems pretty precarious to find 'Magic Tools' via string matching & root GameObject in the scene no? Wouldn't a 'FindObjectOfType<>()' be a better approach?
     
    Last edited: Jan 1, 2022
  37. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hello, and Happy New Year!
    Thanks for this little research, I will try to reproduce the situation on my own. About searching for an object - yes, you are probably right, but I need to search for the root object in order to add an MLS group to it. Thanks for the offer, I'll try to come up with something!

    Regarding errors pointing to Bakery, did you import the Bakery Support package from the Support Packages folder?
     
  38. SEYEDM

    SEYEDM

    Joined:
    Nov 25, 2017
    Posts:
    1
    Hello!

    I'm very much interested in this asset. Wondering if it could also be used for a VRchat project as well.

    Thank you,
     
  39. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hello!

    I think the only limitation is the VRChat library, I don't know which version of Unity it currently supports. Minimum version for MLS is 2019.4
     
  40. Samb88

    Samb88

    Joined:
    Mar 26, 2009
    Posts:
    208
    If the bakery GI volume interpolation works then I would buy this in an instant!
    Is there an update, if this is possible at all?
     
  41. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Lucky you! I finished the Bakery Volume integration a couple of hours ago. There is no update in the store yet, but I will be able to send the patch individually.
     
  42. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hello Eugene,

    i am also interested in the Bakery Volume blending integration.

    Some more questions.
    I have purchased the Built-In RP and the Built-In + SRP version.


    Would i be possible to provide a pure SRP version.
    It s kind of hard that the example scenes don´t work out of the box because
    • Materials from Standard Material Folder are used. You have to convert them.
    • example scene Quick Start doesn t use HDRP setup and Volumes
    • eample scene Skyboy Blending doesn´t uses HDRP Volumes and HDR Sky for blending
    • ...
    So after every update of MLS and when i recommend it to other HDRP users there are always this things to do and to explain.

    Further a patch and unpatch Bakery support would be nice.
    For now i have to import Bakery Support 1.0 package and when i want to remove MLS Bakery support i have to reimport Bakery again?
    I am using Bakery check for patches frequently, around one time per week.
    Only searching the most secure way to use MLS with an often updated Bakery.


    These quality of service extensions would make it much more easy to add and update MLS frequently when you have a row of projects and users.
     
    Last edited: Feb 2, 2022
  43. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    After importing HDRP/URP Support, the scenes are also updated, at least Quick Start. (if I didn't break anything in the last patch). As for a more convenient way to support Bakery - I'll think about what can be done.
     
  44. Samb88

    Samb88

    Joined:
    Mar 26, 2009
    Posts:
    208
    :eek:
    My wallet is ready! :D Thank you very much!
     
    Eugene-B likes this.
  45. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Dou you plan to use the bakery volumes with HDRP?
    I am using the Better Lit Bakery integration for this and i am curious if the MLS SH Directional and the new Volume integration can handle the Better Lit with these Bakery options enabled.
     
  46. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    I haven't tried it, but as far as I know, I've added all the code that Bakery uses to render volumes. So there is a chance this will work on all RPs. At the same time, I don't know anything about integrating with Better Lit. In any case, you can try and if it doesn't work, then I will try to quickly implement support.
     
  47. Samb88

    Samb88

    Joined:
    Mar 26, 2009
    Posts:
    208
    Nope, I target low end hardware and for my case the built in render pipeline is the fastest
     
    keeponshading likes this.
  48. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi there!
    At the moment, payments to all banks in Russia are blocked and I actually do not receive payments from Unity. I continue my work for free - anyone who wants and can provide support can do it here.
    I hope it's all over soon! Peace and good luck to all!
     
    blueivy, KillerJaguar and Inspeinre like this.
  49. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
    Hope all is well! Will definitely be supporting you. Did the bakery volume implementation ever make it to the asset store?
     
  50. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Thank you! Yes, Bakery Volume support is already implemented in the Pro version of the plugin.
     
    blueivy likes this.