Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How to export/save baked lightmap? (Unity 2017)

Discussion in 'Global Illumination' started by filibis, Jul 27, 2017.

  1. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    Is it possible to export/save lightmap for later use? And how?

    I want to bake lights with very high quality which takes long time and save it somewhere, so i can continue editing/tweaking stuff to improve my scene with low-quality, then i can 'recall' higher quality one whenever i wish (when i decided not to change anything).
    ---
    Note: I am aware if i decided to change objects or lights, i need to rebake.
    Note 2: I use Progressive Lightmapper and Unity 2017.1.0f3
     
  2. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    I'm not using 2017 yet, but if this hasn't changed :

    Lightmaps are saved in your project/scene/ folder as .exr
    So you can just copy them from there.
     
  3. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    There is only Reflection Probes as .exr files. Here is how my scene folder looks:

    Unity Folder:
    unity_folder.JPG

    Windows Folder:
    windows_folder.JPG
     
  4. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Weird.
    Search for "Lightmap-0_comp_light.exr" in your assets. Maybe it's somewhere else?
     
  5. TheShock

    TheShock

    Joined:
    Aug 5, 2014
    Posts:
    33
    You can commit all project folder via GIT and then revert any changes, this is the most reliable way. You can see all files, that was changed and undo any of them.

    I use this for the same purposes
     
  6. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    @sylon - There is no other .exr files other than reflection probes in any of the folders. Something changed probably that you didn't notice :)

    @TheShock - This sounds a bit time consuming and complicated. I'm after something more practical so that i can use with ease.

    ---
    I have came across to this question. There @Firedan1176 says:
    I don't know if this is the current solution since everything changes so fast. But i have no idea what kind of script i'm looking for either anyways. Do you have any idea?
     
  7. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Do you have "Auto Generated" checked in your lighting window?
    If so, i think your data is stored in your cache.
    If you uncheck it and generate a new build, perhaps your lightmaps will show up in your assets.

    Hope it helps
     
    filibis and LightingBox2 like this.
  8. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    @sylon is right, you need to manually generate the lighting to store the lightmaps locally in your project
     
    filibis likes this.
  9. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    Thank you @sylon and @kemalakay , yes 'Auto Generate' was on and i unchecked it, then clicked 'Generate Lighting' to build. So now i can see lightmap .png and .exr files in my folder.

    generated_lighting_lightmap.JPG
    Thereby i struggle with second part of my issue, 'recalling' lighting maps. How can i do that?
    I enable 'Auto Generate' and notice my lightmaps stilll stays on folder as built which is cool. But i don't how to retrieve them without calculating the lightmaps again.
     
  10. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    Akshara and filibis like this.
  11. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    That's exactly what i was looking for, thank you very much @kemalakay

    Here is a quick demo of 3 different lightmaps switching in play mode:

    lightmap_switcher.gif
     
    weixiaowang, sylon and kemalakay like this.
  12. jricardomiguel

    jricardomiguel

    Joined:
    Feb 10, 2017
    Posts:
    27
    Mate, how you put this circle with the plant of the building here? Thanks.
     
  13. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    It's called "minimap". I don't remember exactly how i did and i can't access project right now but i combined ideas from couple of tutorials to achieve the result.
    Check this for example: Implementing a Minimap in Unity
    Also try searching "making minimap in Unity" on Google, plenty of tutorials come up.
     
    jricardomiguel likes this.
  14. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
  15. filibis

    filibis

    Joined:
    Apr 3, 2017
    Posts:
    35
    Yes, it works in Unity 2017.1.0f3 as i'm using it. Did you read and followed the steps in github?
     
  16. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
    Yes I followed but the problem is with baking. I have day and night views for a scene. So I removed day/night lights from the scene and created two scenes respectively. Dragged scenes to the Level Light Map Data gameobject-script and baked/stored them one by one. After baking, it switches the lightmaps however it does not give the same result as I see when the lights are on at the scene..
     
  17. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
    Alright, now it seems I am bit closer to solution. Since I was missing the "Notes" section:

    • if you want to use lights that don't have direct lighting baked, then you would need to also load the lighting scene associated with the lightmaps when operating the switch.
    And guess what, they were the spotlights not being rendered. So I will have to load day/night scenes additively, so far it seems to work when I load from editor additively.
     
unityunity