Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

LightmapMagic released!

Discussion in 'Assets and Asset Store' started by marcojacovone, Dec 16, 2015.

  1. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hello!

    I'm Marco Jacovone, developer of LightmapMagic.
    As requested from some users, I create this thread for LightmapMagic support.

    Suggestions and questions are welcome.
     
  2. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    In the meantime, a brief description of the asset:

    LightmapMagic is a UNITY editor extension that allows to define multiple lighting configurations, based on enabled/disabled lights, skyboxes and lightprobes/reflection probes configuration, and switch them at runtime.

    For each configuration, you specify what light should be enabled, what disabled, and what skybox you want to use. LightmapMagic starts a complete process of multiple lightmaps generation by managing scene objects and registering generated maps, light probes coefficients and reflection probes textures.

    You can then switch from a configuration to another with a simple visual call at runtime (or in edit mode of course).

    Features
    • Create multiple lighting configuration
    • Bake single configuration
    • Bake all configuration in one simple step
    • Full Undo/Redo support
    • Clear and simple UI
    • Ideal for mobile
    • You will get all light configuration (for example) for all hours of the day, all reflection probes and light probes will be updated per configuration, so that you can turn off all realtime lights!

    Here's the asset store link: http://u3d.as/kCe

    Take a look at the features video.

     
    theANMATOR2b likes this.
  3. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    So to understand correctly - for a game where you are generating levels procedurally from prebuilt rooms, which might be instanced at different angles to how they were authored - this would allow you to author lightmaps for various orientations of rooms and switch them in as needed? If so, my money is yours
     
  4. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Not understand what you mean with "instanced at different angles"... The workflow should be:

    At development time

    • Once you finished your level, including setup of (baked) lights
    • Create various light configurations (ex. day, night, night with city lights on, ...)
    • For each light configuration LightmapMagic automatically create and store light maps

    At play time

    • LightmapMagic allows you to switch configuration at runtime (day, night, etc.), by switching light maps, light probes and reflection probes. In other words, a complete lighting baked configuration.

    In all configurations, the scene should not change, except for lights.
    Hope I was clear in description.
     
  5. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Hey Marco
    Bought it and tested it and it works great. The ability to bake different light configurations and switch between them is fantastic. And so easy. Would it possible to fade between lightmaps in future?

    Cheers
    Michael
     
  6. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
  7. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi Michael,
    It is possible in theory, and it is a very good idea! I have to make some research about performance behavior...

    I will let you know when I know more.
    Thanks
     
  8. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    There is a very annoying behavior on Unity 5.3 baking process that stops LightmapMagic working...

    I'm writing a work around and will release it soon.

    Sorry.
     
    hopeful likes this.
  9. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Found a temporary solution to the problem. For Unity 5.3+ in file LightmapMagicEngine.cs, replace

    assetPath = AssetDatabase.GetAssetPath (LightmapSettings.lightmaps [j].lightmapFar);

    with

    #if UNITY_5_3
    string curScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene ().path;
    string[] parts = curScene.Split ('/', '\\');
    string sceneName = parts [parts.Length - 1].Split ('.') [0];
    string lightmapPath = Path.GetDirectoryName (curScene) + "/" + sceneName + "/";
    assetPath = lightmapPath + "Lightmap-" + j + "_comp_light.exr";
    #else
    assetPath = AssetDatabase.GetAssetPath (LightmapSettings.lightmaps [j].lightmapFar);
    #endif


    and

    assetPath = AssetDatabase.GetAssetPath (LightmapSettings.lightmaps [j].lightmapNear);

    with

    #if UNITY_5_3
    assetPath = lightmapPath + "Lightmap-" + j + "_comp_dir.exr";
    #else
    assetPath = AssetDatabase.GetAssetPath (LightmapSettings.lightmaps [j].lightmapNear);
    #endif


    This works, but assume to know the exact file name and path of generated light maps, and may be not robusto for the future. I'm awaiting for answers from Unity developers.

    Bye.
     
  10. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    @mensch.mueller
    Experimenting with blending lightmaps, lightprobes, reflection probes, skyboxes....
    Very CPU expensive, but at low resolution very good.

    Take a look, and give feedback!

     
  11. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Hey Marco!
    This looks very useful!

    Wish you a great new year!
    Cheers
    Michael
     
  12. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Another experiment with low-resolution light maps blending using LightmapMagic.
    24 lightmaps, 2 skyboxes.
    Only baked lights, lightmaps and skyboxes are blended.

     
    punk and gameDevi like this.
  13. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Het Guys,

    another feature is coming: lightmap patching!
    Basically, you can switch lightmap for a given object (renderer) only, with one from another configuration.

    Take a look!

     
  14. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    A new version of LightmapMagic is out! Version 1.2.
    With Lightmap Blending and Lightmap Patching!

    Try out!
     
  15. PaavoHapponen

    PaavoHapponen

    Joined:
    Sep 10, 2014
    Posts:
    6
    Hi.
    This works really well for completely static scenes, but I really need to show and hide some meshes in some light configurations.
    I've tried disabling the gameobjects - which unsurprisingly resulted in mismatched lightmaps,
    moving out of view - which resulted in scrambled lightmaps - i'm guessing atlasing is done in some spatial fashion,
    and scaling to 0,0,0 - which resulted in UV error messages and similarly scrambled lightmaps.

    Could you possibly look into this as a feature?
    The need is only to toggle a mesh on and off, and the baked lightmaps to match the presence or absence of the mesh
     
  16. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Ok,
    I am experimenting on this.
    I'll let you know when I've found a solution.

    Marco
     
  17. Skolstvo

    Skolstvo

    Joined:
    Dec 21, 2015
    Posts:
    107
    I can't build a standalone build with Lightmap Magic included.

    Since it uses the UnityEngine namespace with editor specific code. What do I have to comment out to get it to work? Removing the Lightmagic script isn't a solution. Am I the first one to actually try and build a game with this asset?

    Ok I have to comment out the fourth line, very strange why it isn't commented out by default.
     
    Last edited: Mar 17, 2016
  18. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi Skolstvo,
    the problem was the fourth line of LightmapMagic.cs script, as you said ("using UnityEditor.Macros;").
    The problem was already fixed on the development trunk, but it is not yet released.

    Sorry.
     
  19. jpatinop80

    jpatinop80

    Joined:
    Jul 29, 2012
    Posts:
    55
    Hi, nice plugin, I would like to use with Assetbundle or prefabs, this will keep the lightmap info for each instantiate prefabs or assetbundle from web or local??
     
  20. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,
    thank you. LightmapMagic manager the entire light mapping process and collect all output light maps. After, allows to switch them, so there should not be any problem using with AssetBundles.

    With coming version of LightmapMagic you can configure objects to appear/disappear on some light configuration, so light maps number may vary from a configuration to another.

    Prefabs are not supported.

    Marco.
     
  21. jpatinop80

    jpatinop80

    Joined:
    Jul 29, 2012
    Posts:
    55
    Thank you for your response... I need to be clear before purchase.. I have a Runner game, I need all environment with lightmap, but the environment are divided in many parts so I will instantiated randomly while game is running, so if I understand, I can bake all environment individually and add one lightmap to each part of environment, and then I can instantiate each part of the environment and lightmapMagic will add the lightmap to each instantiated part of the environment?
    when you said prefab are not supported you mean, the lightmap will be outside the prefab, but the prefab can have the plugin and adding the lightmap isn´t?
     
  22. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,
    some information.

    Lightmapping is a global process in the scene, so you have to start the light mapping process on the entire scene, comprensive of all objects. This is because objects in a part of the scene may cast shadows or influence with direct/indirect light objects in another part.
    Newly created objects (prefabs) are not mapped on existing light maps (i.e. lightmapIndex = -1), so you have to light map all and eventually disable what you wan't see, not instantiate it. The general rule is that you instantiate dynamic objects, not (lightmap)static objects.
    In the coming version of LightmapMagic, you can have different objects in different configuration. In other words, you can have conf1 with objects A,B,C and conf2 with objects A,B,D. So changing configuration will enable/disable game objects (A,B,C,D) and switch light mapping accordingly.

    What you can do with prefabs is:

    1) You can bake all possible (random) pieces of the scene, then with a small c# script save lightmapIndex and lightmapOffsetScale of the MeshRenderer script, save the piece as prefab.
    2) When you instantiate the prefab, restore lightmapIndex and LightmaOffsetScale with saved values.
    3) In this mode, however, light maps have to be baked for all possible pieces, also if you never instantiate it in a given game.
    4) If you need support to create the script, please contact me. I have already tested this technique.

    In this scenario you don't need LightmapMagic.

    Thanks,
    Marco
     
  23. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
  24. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    This is very cool... can it switch Reflection Probes as well?
     
  25. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Yes! You can switch Lightmps, reflection probes, lightprobes, and light and game objects state.
    You can also patch light maps (switch to a light map the entire scene, but set another light map for single gameobjects), and blend light maps, such as 50% day and 50% night; light probes and reflection probes can also blended too.

    Thanks for your interest.
    Marco
     
  26. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    It would be great if you could rebake only reflection probes.
     
    Last edited: Nov 14, 2016
  27. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi StaffanEk,

    I registered your contribute, many thanks.
    For bake reflection probes only, you can simply add a button that calls

    Lightmapping.BakeReflectionProbe(...);

    Regards,
    Marco
     
  28. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    317
    Hello there,

    Thanks for a great asset – I find it really useful and generally it works well.

    I’m having a similar issue with light importance as per the other thread ‘Scene Falls Back on Realtime Lighting’, and only in builds. Everything works just fine in the editor.

    In builds — If I set all my lights to ‘Render Mode’ as ‘Not Important’ the game runs fine. However if I set any lights to ‘Auto’ or ‘Important’ the build crashes as soon as my player camera turns towards the light in question.

    In my project I’m baking lights and using additional lights for real-time shadows, so I need the importance of those lights to be different, otherwise they don’t show up correctly.

    Any idea how to handle this issue, is it related to LightmapMagic or Unity do you think?

    Also posted on your support forums:
    https://jacovone.com/wordpress/?topic=light-importance-and-unity-crashes-in-builds/#post-2657

    // WildStyle
     
  29. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    Light for teal time shadows have to be in "mixed" style, not necessarily important.
    Can you send me an extract of your project that show up the issue?

    What version of unity are you using?

    Regards,
    Marco.
     
  30. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    317
    Thanks @marcojacovone -- already confirmed that it's a Unity bug with 5.6 in forward rendering, single-pass.

    // WildStyle
     
  31. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    Hey @marcojacovone!

    Love the asset. Two things:
    1. Did you delist it from the asset store? it's not coming up.
    2. Getting this bug in 5.6.2
    Code (CSharp):
    1. The renderer Barrel (3) is a part of a static batch. Setting the lightmap scale and offset will not affect the rendering. The scale and offset is already burnt into the lightmapping UVs in the static batch.
    2. UnityEngine.Renderer:set_lightmapScaleOffset(Vector4)
    3. Jacovone.LightmapMagic:SwitchRenderers(Int32) (at Assets/LightmapMagic/Scripts/LightmapMagic.cs:482)
    4. Jacovone.LightmapMagic:SwitchConfig(String, Boolean) (at Assets/LightmapMagic/Scripts/LightmapMagic.cs:253)
    5. Jacovone.LightmapMagic:SwitchConfig(String) (at Assets/LightmapMagic/Scripts/LightmapMagic.cs:200)
    6.  
     
  32. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    starting from a recent version of Unity, Unity suggests that the game object that participate to the static batch process (i.e. The MeshRenderer's GameObject is batching static) should not modified in terms of light map parameters, such as scale and offset. This because the object is not longer rendered in the original form, but batched together with some other static meshes.

    The strange behavior is that it continue to work correctly, but give the warning message.

    Probably in the near future it will not work anymore.

    The frequent changes to the lighting model is the main reason for me to deprecate the project.

    Remove the static batch flag from these game objects, or use the plugin with older version of Unity.

    Regards,
    Marco