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

Bakery - GPU Lightmapper (v1.71) + RTPreview [RELEASED]

Discussion in 'Assets and Asset Store' started by guycalledfrank, Jun 14, 2018.

  1. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    Well shadow masking uses extra processing power, i'm hoping for full lighting, and casting dynamic shadow from my character, without masking. I can just make my shadow lighter.
     
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Not sure this is possible, sorry. Unity doesn't support that. You can perhaps hack the shadow using projector.
     
  3. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    I've actually been doing that with unity progressive light mapper, with subtractive mode.
     
  4. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,075
    I created a follow-up thread in the Unity Scripting forum to find out the details on how/why the "Anatomy of a Mesh" page says UV coordinates are limited to the 0...1 range. That page differs from the actual scripting API reference, which mentions no such limit, and I provided a screen shot in Blender of a valid use-case for coordinates well outside that range.

    @guycalledfrank I'm hoping that the Unity team will respond back to clarify the documentation, one way or the other. I agree with you that you have correctly implemented what is on that documentation page; my assertion is that either the documentation may be wrong, or Unity may have an internal bug in the way they handle UV coordinates. Either way, we should learn something useful.
     
    guycalledfrank likes this.
  5. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    I can't reproduce this on a new project. But on my own project, I can get bake using shadow mask mode and get the light probes to work. But for Full Lighting mode, my light probes don't receive shadows. I know I'm doing something wrong because the demo project sent you is working fine, but I can't figure out what I'm doing differently to not get the probes working in full lighting mode... Any insight?
     
  6. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    I found out the reason now. The building that is casting a big shadow, it is a object that has LOD group. I disable the LOD and then the light probes now receive shadows. So I'm guessing this is a bug from bakery. Please let me know your thoughts. thx
     
    guycalledfrank likes this.
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Ah, hmm. Well subtractive mode is up to the engine - there is no additional data baked. You can't get it working though? Maybe I just need to set some flag on the light.

    Note that general UV coordinates are different from lightmapping coordinates. Latter are usually expected to be 0-1, while former not. I see how you can still pack non-0-1 UVs in the lightmap atlas, but that's a bit unusual.

    Does the building itself has LOD0? So it's always visible up close? But seems like a bug, yeah... I'm gonna check it now.

    EDIT: seems like I found the problem. Can you try a quick fix? Go to ftRenderLightmap.cs, find this line:
    flmlod.Write(-1);

    and replace it with
    flmlod.Write(0);
     
    Last edited: Sep 21, 2018
  8. b4th

    b4th

    Joined:
    Jul 4, 2016
    Posts:
    65
    Feature Requests:

    Most exciting: Would it be possible to add support for multiple "lightmap profiles" for a single scene - for instance day and night - and be able to switch between them at runtime without reloading the entire scene?

    Intriguing: Would it be feasible to support 'additive' lightmaps for individual lights or light groups (allowing for light-switch functionality). I imagine this could only be done for one or two light groups, or it might balloon the memory/storage requirements?

    Kind of interesting: Would it be possible to treat regions of a scene as separate 'worlds' with separate light bakes? I suppose it might make more sense to split these regions into separate scenes, bake their lighting, and load them additively at runtime?
     
  9. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Hell yeah - I'm planning to add support for doing these things without a hassle. Right now you'll need to script it (the same way as with built-in lightmaps).

    The problem here is that lightmaps are generally compressed (for a good reason), and to combine two, you'll need to decompress->add->compress, and this is quite slow (compression takes many seconds).
    Without compression it's fast, but I'd rather prefer using compression and adding multiple lightmaps in the shader, or simply having switchable multiple versions of the lightmap (room with lights on and off). Of course in the latter case if you want to toggle 4 lights, then you would have to bake all possible combinations (16?!), and that's bad. On the other hand, if I want just one light, it's cheaper than any additive stuff.

    Yes, you can already do that (bake scenes separately, then add together). Lightmap Groups should also help with that, and for the next version I'm adding render mode/directional mode options for groups. That means you can have SOME objects using directional lightmaps, some using shadowmasks, some using just one color. Not being able to do it in Unity out of the box always bugged me.
    Basically all global bake settings can be moved to groups and then used on selected objects.

    upload_2018-9-21_12-25-57.png
     
    Archviz3d and b4th like this.
  10. etneterapks

    etneterapks

    Joined:
    Jul 20, 2017
    Posts:
    1
    Hi, I'm trying to bake relatively simple scenes both contains the same prefab which is tiled highway, they are not static, only lightmap static in Mesh Renderers. First scene was baked easily and fast and looks good, but the second scene, which is basically identical, keeps crashing the whole PC (running on i7, 1080ti, driver 391.01, Unity version 2018.2.5f1). Any Idea?
     
    Last edited: Sep 21, 2018
  11. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Hi! I need to know what error exactly do you get and at which baking stage it happens (what was the last thing written on the progress window).
     
  12. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,075
    Absolutely agree. In spite of the similar names, Visible UV and lightmap UV are very different maps for different purposes.

    EDIT: Here is my suggestion: Continue to throw the warning (non-fatal) for UV2 coordinates outside the 0-1 range. If your code falls back to UV1, in that case suppress the warning.
     
    guycalledfrank likes this.
  13. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    I end up getting to work. I had to select subtractive mode in the Unity's light map tab. I didn't know bakery uses those settings!
     
    guycalledfrank likes this.
  14. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    That indeed worked! Thanks!
    I was wondering, in unline "shadow mas"k mode in full lighting mode, whether I check "Occlusion probes" or not it still works to bake the light probes properly. Why is that? And should I check that box?
     
    guycalledfrank likes this.
  15. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Not sure if I got your question correctly. Are you asking why occlusion probes are not needed in full lighting?
    Occlusion probes are just values containing occlusion of real-time lights. If you don't have any real-time lights enabled (all are baked) then you don't need occlusion probes (you have nothing to occlude).
     
    nepoez likes this.
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Well it doesn't - as I said subtractive mode is up to Unity, it just takes standard lightmaps (no matter what lightmapper produced them) and subtracts dynamic shadows from them. That's it. I guess I should add the subtractive checkbox to Bakery UI, so you don't have to switch between windows.
     
    nepoez likes this.
  17. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    36
    Hi Frank, i think i found a bug
    1. Bake scene with Bakery
    2. Clean scene lightmap data
    3. Bake with unity progressive
    4. Play scene
    Result: the data baked by unity is still here but ALL renderers lightmap indexes will be force incremented by 1 and pointing to empty lightmap. After exit from play mode indexes stay damaged. If i remove Bakery from project without scene save and then stat play - all seems good.
     
    guycalledfrank likes this.
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Was Bakery main window open or closed? Opening it can re-initialize some data.
     
  19. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    36
    It was opened and docked. I mixing bakery and unity progressive in my project since i need baked directional in some of them (desperatly waiting for next version of bakery with this feature), so the main hazard of this bug - if i save scene directly after play - the long waited progressive bake will be lost. I was tried to change indexes by script but it ending in no good ( i think its because this renderers participate in static batching).
     
    Last edited: Sep 21, 2018
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Try closing the window, clearing Bakery data and then using Progressive.
     
  21. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,178
    I have a GTX 750 Ti, will this tool work with it?
     
  22. Scarabay

    Scarabay

    Joined:
    Sep 7, 2013
    Posts:
    12
    So will you add this option?

    Definitely yes! Will it be included in 1.4?
     
  23. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Yes it should work.

    I probably should! Will see if I can make it for the next release.

    Would be cool to include, but I'm not sure, as they're pretty unpolished at the moment (there is no proper UI, and decal geometry contains some redundant vertices). I should focus on getting directional lightmaps done first.
    I'm also thinking of releasing them as separate asset, because they don't really depend on Bakery, you can use them with built-in lightmaps as well.
     
    syscrusher likes this.
  24. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,178
    One thing I didn't understand: does your solution NEED your special shaders to work, because of the bicubic final filter on the textures, or is it working seamlessly with the Unity Standard Shader?
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Nope :)

    Yes!
    Even bicubic integration is compatible with standard shaders (and it's optional).
     
  26. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Continuing my work with directional lightmapping modes. So far I implemented 4 different modes:

    upload_2018-9-22_13-46-20.png

    "Baked normal maps" is only useful as reference or for mobile. Maybe for LODs. It's just a standard lightmap with bump mapping baked in. Normal detail will lose resolution, but on the other hand, the lighting is very precise and can be used as ground truth to compare other methods with.
    "Dominant Direction" is the default Unity mode, what they call directional. Uses 1 additional non-HDR map.
    "RNM" is the technique originally used in HL2, and then also in other games, e.g. Mirror's Edge. Uses 2 additional HDR maps.
    "SH" is a spherical harmonics representation with some tricks, based on Frostbite paper. Uses 3 additional non-HDR maps

    Some comparisons:

    upload_2018-9-22_14-16-15.png
     
    Last edited: Sep 22, 2018
    CoastKid, neoshaman, Mark_01 and 6 others like this.
  27. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,178
    Wow SH by far the best!
     
    hopeful and guycalledfrank like this.
  28. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,075
    That article by Valve from 2004 really shows just how much that team has pushed the boundaries of gamedev over the years.
     
    guycalledfrank likes this.
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    It was absolutely mind-blowing back then! In some scenes it is really amazing and gives noticeably better results than single direction:

    (my old explanation pic)

     
  30. b4th

    b4th

    Joined:
    Jul 4, 2016
    Posts:
    65
    Do Spherical Harmonics / RNM approaches require changes to the Standard shader?
     
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Yes, but I'm thinking of adding an option to the Shader Tweaks menu, so it can be injected into all existing shaders (the way bicubic filtering works).
     
    b4th likes this.
  32. matthewlebo

    matthewlebo

    Joined:
    Mar 16, 2016
    Posts:
    7
    This is a very impressive asset. Buying this right away! Worried UNITY is going to hire you and leave us without your clearly amazing support... :p
     
    neoshaman, tntfoz and guycalledfrank like this.
  33. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    Hi! In unity's lighting tab there's a "compress lightmap" checkbox. For Bakery, if I want the same function what should I do? Thanks.
     
  34. Milanis

    Milanis

    Joined:
    Apr 6, 2018
    Posts:
    55
    May i ask a couple of questions regarding Bakery. First, very impressive pictures - i really like the fidelity and quality.

    #1 Does Bakery only work with its embedded Materials - within are they compatible with the new render pipeline in the near future?

    #2 Does it support PBR/PBS - within Textures from Substance Designer/Painter or even Substance Plugin based materials (possible future addition)

    #3 While its not meant for realtime, would Bakery be able to bake lights and AO on Assets for inside (Buildings) and outside (Buildings and Props) and then importing/re-using these baked assets on realtime-GI terrain maps/landscapes. (Example: Baking some GI/AO without sunlight, then adding the realtime solution on top of it. Most thinking about Day and Night Cycles here)

    #4 Based on this picture:

    .. i'm pretty interested how big the lightdata might be on scenes like this and if it could be possible to "load" different baked lightmaps on runtime. I am thinking about a day scene without baked sunlight and a version for night where i can load in another lightmap with baked lights for street lights, enlightend windows, etc.

    Thank you and have a good start into the week!

    Toby
     
    guycalledfrank likes this.
  35. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Just select lightmap assets and change their compression after bake.

    Bakery supports all materials including Standard, LWRP, HDRP and anything custom.

    Bakery just bakes lightmaps. There is no compatibility issue with other material functions.
    Note, however, that latest public version doesn't bake directional information - meaning you won't get bump mapping in purely lightmapped areas without using mixed lighting. v1.4 will fix that.
    In general you can get the idea of how materials are going to behave by using Enlighten/Progressive in non-directional mode.


    Again, if you can do it with built-in lightmappers, you can do it with Bakery. As for re-using, there is a way to get baked prefabs working, but it's not easily doable through UI at the moment.

    You don't see the whole scene, it's bigger than that. Looks like this actually. Uses single 4096x4096 lightmap. I auto-unwrapped the whole scene in 3dsmax, so it's pretty dense, Unity unwrapper may give slightly worse results.
     
    Last edited: Sep 24, 2018
  36. Milanis

    Milanis

    Joined:
    Apr 6, 2018
    Posts:
    55
    Wow, thanks for the fast and detailed reply. Guess you've just got a new customer.
    Can't wait to take a look at your baby. Thank you guy called Frank. :D
     
    guycalledfrank likes this.
  37. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    255
    It is somehow possible to bake shadow mask in full resolution, and indirect map in half or even quad-res?
     
    guycalledfrank likes this.
  38. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    111
    You can change resolution after bake.
     
  39. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    255
    This introduce light leaking in some places. At now i bake low-res lightmap and move indirect map to another folder, then bake high-res lightmap and bring low-res indirect back. It's works, but 1-button bake will be much nicer.
     
  40. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Sounds like a very good idea - I should definitely add this option!
     
  41. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    I encountered this today. 2 things I did differently, one is changed from linear to gamma because of gles 2.0 support, the other is my gpu is overclocked. I don't know if either of these 2 can cause this issue? Any insights?
    upload_2018-9-24_11-5-38.png
     
    Last edited: Sep 24, 2018
  42. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    What I did for this is select all the lightmap assets for masks and changed the resolution in inspector, and change the assets for indirect to get different res for these assets. Is that ok?
     
  43. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Do you happen to have many Light Meshes in the scene? If so, I fixed this bug recently and can send you the fix.

    Shrinking lightmaps/masks may introduce some light leaking, as BattleAngelAlita noticed. Ideally UV padding should be applied using the lowest resolution map to avoid it. Something I should do.
     
  44. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    What is a light mesh?
     
  45. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    It's one of Bakery's light components.
    Do you have any area lights?

    Also: does it happen during GI or other pass?
     
  46. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    No I don't have any of that. I didn't change my scene. I have baked this set of scenes multiple times and it's fine. Until today, and the only 2 things I did differently is change to Gamma space, and my gpu is overclocked(which I don't know if it's worth mentioning even but I stopped overclocking it just to get that variable out of the picture).
     
  47. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    ok I just got error again, this time: upload_2018-9-24_11-34-58.png
     
  48. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    OK I did see a warning, maybe it's due to this, I am doing full light mode and in unity lightmap tab I have shadow mask still. Maybe that's why? Let me fix that setting to match and try again and I'll report back.

    The loaded level has a different lightmaps mode than the current one. Current: Non-Directional. Loaded: Directional. Will use: Non-Directional.
    UnityEditor.SceneManagement.EditorSceneManager:OpenScene(String, OpenSceneMode)
    ftRenderLightmap:LoadScenes() (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:260)
    ftRenderLightmap:progressBarEnd(Boolean) (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:466)
    ftRenderLightmap:DebugLogError(String) (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1034)
    <RenderLightmapFunc>c__Iterator2:MoveNext() (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:3170)
    ftRenderLightmap:RenderLightmapUpdate() (at
     
  49. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Is it without overclocking now? What was the last text you saw on the progress window?

    That's some meaningless error Unity sometimes shows when multiple lightmapped scenes are loaded, shouldn't be a problem.
     
  50. nepoez

    nepoez

    Joined:
    Sep 11, 2011
    Posts:
    298
    Shucks, the overclock was still on due to the software startup on boot by default. Let me try again with a clean boot. I hope that's the issue because I don't know why it was working so well all week until today. So you don't think it's caused by switching to gamma right?
     
    guycalledfrank likes this.
unityunity