Search Unity

[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. virtualjay

    virtualjay

    Joined:
    Aug 4, 2020
    Posts:
    68
    Does MLS change something global in your Unity installation? Or some global user setting across multiple projects?

    I ask because a coworker who installed it in one project started having problems in another project, where it was not installed. It showed the purple dot icon in the tab of the hierarchy, and it threw a bunch of errors along the lines of
    Shader error in ________________: Unexpected token '('. Expected one of: ',' ';' at MLS_Standard_Common.cginc(121)
    12:32 PM

    With ________________ being the name of various non-MLS shaders. The file MLS_Standard_Common.cginc is nowhere to be found in the entire project folder.

    He went so far as to delete the entire folder and check it out of version control again (the same one I use), where there isn't a Magic Lightmap Switcher folder under Assets and no MLS_Standard_Common.cginc at all. Once Unity had opened the new project and re-imported everything, he got the same error.

    This is in Unity 2020.3.20 LTS.
     
    UnivrseCore likes this.
  2. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Use shaders patch for all projects where you use plugin
     
  3. virtualjay

    virtualjay

    Joined:
    Aug 4, 2020
    Posts:
    68
    I feel like you might have misunderstood. We're talking about a project where he does NOT use the plugin. That's the project that is failing, with complains about MLS.
     
  4. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Yes, now I think I understand. When you patch the Standard shaders, MLS makes changes to the global shaders, but this hasn't been seen before. I will try to check it tomorrow.
     
  5. virtualjay

    virtualjay

    Joined:
    Aug 4, 2020
    Posts:
    68
    Okay, thanks. He's switching back to his home machine, where he's not seeing the problem. If you need any other debug information just let me know.
     
    Eugene-B likes this.
  6. CMG2

    CMG2

    Joined:
    Oct 12, 2020
    Posts:
    3
    I am using Unity 2020.3.20f1 version.
    I created an empty URP template project as per the documentation and then set the Configurable Enter Play Mode option.
    Then I opened the Magic lightmap Switcher (Built-In + SRP) through the Package Manager.
    When I opened LMS URP Support 1.4.1, I checked that the same shader error as in image 1 appeared, but I did not know how to solve this, so I ignored it for now.
    (The manual says that SRP is not needed, so I ignored it. When Prepare Shaders.. was pressed, a warning window like the 3rd image appeared and could be closed. At this time, the console window was in the same state as the 2nd image.)
    When I opened the Quick Start scene and clicked Create New in MLS Manager - Switching/Blending, a warning window like the 3rd image kept popping up and I couldn't check the sample scene anymore.
    Please help me.
     

    Attached Files:

  7. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Looks like a bug where MLS couldn't determine the path to the working folder or it's write-protected. Try moving the plugin folder to the root of the Assets folder, just to be sure. Also, before patching shaders, make sure that the URP and Core RP are not in Custom packages (this can be checked through the package manager). If they are there, then you need to remove them and reinstall them and only then perform the shader patch. If you can't solve the problem, then connect to the Discord server, where we can sort out your problem in detail and quickly.
     
  8. CMG2

    CMG2

    Joined:
    Oct 12, 2020
    Posts:
    3
    I've never put the plugins folder in a path other than the Assets folder. And since it was created as a URP template when creating a project, I confirmed that both URP and Core RP were installed properly.
    I think I'll have to use Discord to solve it.
     
  9. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Ok, write something in Magic Lightmap Switcher #discussion channel, or DM me
     
  10. shma_unity

    shma_unity

    Joined:
    Jun 13, 2018
    Posts:
    118
    Hello,

    I've recently bought and integrated lightmap switch for my project, and I really like it.

    However, I think I found an issue.
    When in switching-only mode, the light intensity doesn't get set for the additional HDRP data, so only the lightmap changes, but not the direct light intensity.

    The problem is fixed for me when adding

    Code (CSharp):
    1. #if MT_HDRP_7_INCLUDED || MT_HDRP_8_INCLUDED || MT_HDRP_9_INCLUDED || MT_HDRP_10_INCLUDED || MT_HDRP_11_INCLUDED || MT_HDRP_12_INCLUDED
    2.                     HDAdditionalLightData additionalLightData;
    3.                     if ((additionalLightData = lightSources[i].gameObject.GetComponent<HDAdditionalLightData>()) != null)
    4.                     {
    5.                         additionalLightData.intensity = currentLightData.intensity;
    6.                     }
    7. #endif
    At line 208 of Switching.cs.


    Another small problem I found was that reflection probes were baked at the wrong settings.
    I have a HDRP settings volume for each light preset (day, evening, night), and I'm using the game object presets to activate only one of them per preset. Everything works, except for the first preset, which baked the reflection probes with the wrong hdri environment.
    I've seen that there are HDRP blendables, but I'm not sure how they work when switching between volumes. However, using them seemed to have fixed my problem somehow, and the reflection probes now bake correctly. Maybe I have just misunderstood how to use the HDRP blendables correctly.

    It would generally be a really cool feature if I could define an active set of HDRP volumes per lighting preset (since they also contain specific tone mapping and exposure for each light setting).
     
    Howard-Day likes this.
  11. Silvax90

    Silvax90

    Joined:
    Dec 28, 2017
    Posts:
    2
    Hi, I have an issue trying to switch the skybox texture in different presets in HDRP. While loading the preset and the skybox texture attached, skybox is not changing and there is no error in the editor. I tried no to use the volume HDRSky but it has no difference. Also the exposure value is not switching too.

    Unity 2020.3.17f1c1 HDRP
     

    Attached Files:

  12. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi! You need to manage the skybox in HDRP through Custom Blendable, however, at the moment there is a bug because of which this does not happen properly. I'm working on this problem.
     
  13. Silvax90

    Silvax90

    Joined:
    Dec 28, 2017
    Posts:
    2
    I wrote a Custom Blendable script, the variables appeared in the preset setting, but after loading this preset , the sky cubemap and the exposure values in the HDRI Sky hadn't change. Am I missing something ?
     

    Attached Files:

  14. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    No, its s bug, Im working on it right now.
     
  15. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Hello. I have a Unity 2021.3.12f1, HDRP 12.1.7 and Magic Lightmap Switcher 1.1.1. I found that patched HDRP shader makes all the surfaces glossy. Patched shader:
    upload_2022-11-13_23-32-56.png
    Not patched shader:
    upload_2022-11-13_23-37-41.png

    It's a big problem for me. Any fixes?

    [UPD] Same problem on fresh projects on 2020.3 and 2019.4 HDRPs.
     
    Last edited: Nov 13, 2022
  16. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hello! It seems that this problem has already been fixed in the new version, which has not yet been published. As a temporary solution, change the Convolution Type in the properties of the Reflection Probes asset.

    upload_2022-11-15_3-55-58.png
     
    ftejada likes this.
  17. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Thank you for the answer! I trien to switch the Convolution Type to Specular and get this:
    upload_2022-11-17_1-19-53.png
    Reflections on metals become additive or something like that, at least it's too bright )

    Seems like I'm waiting for an upcoming update!
     
    Last edited: Nov 19, 2022
  18. Lamb0Fett

    Lamb0Fett

    Joined:
    Oct 3, 2014
    Posts:
    3
    Hey! I purchased this yesterday and should have asked prior to buying. If I have a lightmapped bakery prefab ( using lighting volumes) and want to use the plugin to purely swap between the first generated lightmap and a second one, can this plugin be used to swap between already generated assets?
     
  19. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi, Bakery Lightmapped Prefab doesn't support at the moment.
     
  20. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    @Eugene-B

    MLS: Patch error of [EntityLighting.hlsl, GlobalIllumitation.hlsl] Unity version: 2021.3.18f1. Render Pipeline: URP 12.1.10
    Show the text of this error to the developer.
    UnityEngine.Debug:LogErrorFormat (string,object[])
    MagicLightmapSwitcher.MLSShaderCodeModifier:printPatchReport (MagicLightmapSwitcher.MLSShaderCodeModifier/RenderPipelineType,System.Collections.Generic.List`1<string>) (at Assets/Magic Lightmap Switcher/Editor/MLSShaderCodeModifier.cs:591)
    MagicLightmapSwitcher.MLSShaderCodeModifier:CheckForSRPPatched (MagicLightmapSwitcher.MLSShaderCodeModifier/RenderPipelineType,bool) (at Assets/Magic Lightmap Switcher/Editor/MLSShaderCodeModifier.cs:1275)
    MagicLightmapSwitcher.MLSShaderCodeModifier:patchSRPShaders (MagicLightmapSwitcher.MLSShaderCodeModifier/RenderPipelineType) (at Assets/Magic Lightmap Switcher/Editor/MLSShaderCodeModifier.cs:3046)
    MagicLightmapSwitcher.MLSShaderCodeModifier/<PrepareSRPPackage>d__74:MoveNext () (at Assets/Magic Lightmap Switcher/Editor/MLSShaderCodeModifier.cs:957)
    MagicLightmapSwitcher.MLSShaderCodeModifier:prepareSRPPackageSRPIteratorUpdate () (at Assets/Magic Lightmap Switcher/Editor/MLSShaderCodeModifier.cs:153)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
     
  21. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    The problem has been solved in the new version, which has not yet been published. Connect to the Discord server please and send me your invoice in the DM. I will send you the new version directly.
     
  22. transcosmos

    transcosmos

    Joined:
    Feb 5, 2016
    Posts:
    3
    Hello

    It's a rudimentary question.

    While looking at gitbook, I checked the operation with quick start.
    I want to check the blend function.
    4.2. In the item of Lightmap Blending
    Blending Configurator UI is not displayed.

    Please tell me how to display it.

    Unity2021.3.9f1
    Magic Lightmap Switcher (Built-In + SRP) Version 1.2.0
     
  23. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    If you haven't patched the shaders or clicked "Use Switching Only" or doesn't set the "Create Lightmap Scenario" option in the "Storing" tab, no blending will be shown. Also, I found, inaccuracies in the manual. I will correct it now.
     
  24. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Hi @Eugene-B , is this asset compatible with (larger) terrains? I guess the performance will be better than Enviro realtime + terrain? Thanks in advance!
     
  25. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    We are talking about different assets. Enviro uses real-time lighting, while MLS uses baked lightmaps. At the same time, Enviro allows you to get realistic lighting depending on the time of day and weather, while MLS can mix various pre-baked lighting maps.
     
  26. theglimpsegroup

    theglimpsegroup

    Joined:
    Oct 18, 2017
    Posts:
    2
    I also have this problem in a project that isn't using MLS - Did you find what files were changed and how to fix them?
     
  27. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    These files are located in the UnityVersionInstallFolder/Editor/Data/CGIncludes folder. All modified files are located next to their original copies, whose names end with _backup. You can restore the original files manually or open a project in which you use MLS and in which you performed a shader patch and undo it from there.
     
  28. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15
    Hi,
    I've purchased the assets and i'm trying to switch lightmaps with also lighjtprobes created with magic light probes.
    After the bake of the two variants in two different scenarios, i get the switch of the lightmaps only on the scenes that are in the game view.
    furhtermore if i don't have a camera in the scene the switch doesnot happens at all.

    can someone help me understanding where is the problem?
    thanks.
     
  29. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Hi!
    I have already added disabling this behavior in the new version, however it has not been published yet. You can just comment out a line in the code to ignore it.
    Blending.cs
    upload_2023-12-19_17-20-10.png
     
  30. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15

    also commenting this lines the problem of the switch persists.
    If I try to swap the scenarios, or just the presets inside the same scenario in editor the swap of lightmaps happens only to the objects that are visible in scene view, and at runtime i only get swap for the objects that are viewed in the camera frustum.

    I've tryed on another project and the problem is not there, so the problem is in my project.
    Can you help me understand what is happening?
    This is quite a big project, so i cannot change project.
    Maybe there is something that i could do?
     
  31. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Connect to the Discord server, we will discuss the problem in more detail. In a nutshell, what you're talking about shouldn't happen, at least I handled this situation in the code separately.
     
  32. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
  33. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
  34. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    The documentation states "If you are using or intending to use the NGSS (Next Gen Soft Shadows) plugin, then you first need to follow the steps to install NGSS. Since NGSS patches the original CGIncludes files. This will undo the changes made by the MLS."

    I'm confused, do I use the cginc files from NGSS or the ones from MLS?
     
  35. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    The following error keeps popping up when trying to switch between lightmaps at runtime. It seems as though the light probes are missing, do they need to be referenced somewhere?

    NullReferenceException: Object reference not set to an instance of an object
    MagicLightmapSwitcher.Switching.LoadLightProbesData (MagicLightmapSwitcher.StoredLightmapData lightmapData) (at Assets/Extras/Magic Lightmap Switcher/Switching.cs:299)
    MagicLightmapSwitcher.Switching+<LoadLightingDataAsync>d__4.MoveNext () (at Assets/Extras/Magic Lightmap Switcher/Switching.cs:85)
    MagicLightmapSwitcher.Switching.LoadLightingDataIteratorUpdate () (at Assets/Extras/Magic Lightmap Switcher/Switching.cs:26)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <06837d428b6d46f581d93f9597703696>:0)
    fdgdf
     
  36. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    First you need to install NGSS, then patch the shaders through the MLS menu.

    Which version of MLS are you using?
     
  37. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    So the UnityShadowLibrary.cginc that get's installed by NGSS is overwritten by MLS?
    I'm using the latest version 1.96.3 of MLS.
     
  38. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    The UnityShadowLibrary.cginc that get's installed by NGSS is overwritten by MLS, and NGSS will still work 100%?
     
  39. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    MLS does not replace the file completely, it only finds the necessary lines in the file and replaces them. Try to do as indicated in the instructions, if there are problems, then come to the Discord server, I will prepare these files for you individually. At the same time, I'll check if something has changed in the new version of NGS and if it still works.
     
    Graham-B likes this.
  40. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    I imported the plug-in into the hdrp project and threw this error, I did not find any classes or data structures related to "EnviroSky" in the plug-in, may I ask if there is missing code or this definition does not exist? The pipeline is hdrp, thank you!
     

    Attached Files:

  41. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    I met a problem, I baked lightmap in hdrp scene, but after I baked it once, this popup window would pop up to me. This popup window is a plugin, because lightingmap does not have data, it will always clear my lightData, I would like to ask if anyone has encountered the same problem or knows the solution, thank you
     

    Attached Files:

  42. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    This only happens if the lightmaps have not been baked.

    Possible reasons:
    1) There are no light sources in Baked or Mixed mode
    2) There are no static objects on the scene
     
  43. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    Hello, does this plug-in support the baking of light probe?
    I put the objects' Lightings->Light Probes, set them all to static, and started baking, but I couldn't find the baking map, was it not supported by the plugin or was my setup wrong?
    Thanks!!!
     

    Attached Files:

  44. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Do you have static objects on scene and light sources in Mixed or Baked mode?
     
  45. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    When I'm baking, the object is set to static, and I have a light source in my scene, but it's not static
     
  46. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Do you need light sources in Baked or Mixed mode to bake lightmaps
     
  47. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    Thank you. My purpose is that I want to switch between tiles by Lighting Probes, but at present, I am told that no bakes lightmaps found int the project, what can I do to solve it
     
  48. Eugene-B

    Eugene-B

    Joined:
    Sep 7, 2014
    Posts:
    323
    Actually, I don't quite understand what it's about. What is "tiles"? Maybe you can record a short video of the demonstration? In any case, lightmaps will be baked only if there are static objects on the scene on which they can be baked. Try baking lighting without using MLS and see if anything changes. In the end, MLS just calls the standard Unity lighting baking process, then waits until it's over, and then copies the generated files to the right places.
     
  49. unity_3suXl_dUMh29XQ

    unity_3suXl_dUMh29XQ

    Joined:
    Sep 6, 2023
    Posts:
    8
    You can provide a specific contact information and then we can talk about it. Thank you
     
  50. lc-gd

    lc-gd

    Joined:
    May 14, 2019
    Posts:
    6
    Hello. I purchased the asset today and I am getting the following compilation errors when opening the asset in Unity 2023.2:
    upload_2024-4-24_17-12-25.png

    When can I expect the errors to be fixed?