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

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

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

  1. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Hmm. You can build without the terrain? TBH, I didn't realize that. Will see if there is some way to detect it. Thanks for noticing!
     
  2. eluukkanen

    eluukkanen

    Joined:
    Oct 1, 2015
    Posts:
    26
    Looks great! Keep it up
     
    guycalledfrank likes this.
  3. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Posts:
    22
    One of the major things for me is the ability to export to a texture file! I can do fun things in Photoshop and by processing the same UV set with other tools like Worn Edges to create more textures that I could blend at runtime for additional effects.
    As long as the lightmaps are outside of my access area I only gain the faster processing (which of course would be awesome), but my main gripe is the lack of access to do all the fun things I currently do with textures.
     
  4. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Note that:
    - Lightmaps are HDR (16-bit)
    - Because there are HDR format limitations, they have different encoding depending on platform
    - You'll need to write your own shader

    If you're OK with that... you can already use Bakery:
    - Use the Lightmap Group Selector component to define which objects will be baked to which lightmaps.
    - Clear baked scene data to remove regular engine lightmapping.
    - Open lightmaps in photoshop and edit them the way you want.
    - Insert them into your shaders.

    I can perhaps write a tutorial on that.
     
  5. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Posts:
    22
    That seems to be too much of a workaround - especially as I am fairly dependent on the standard shader for many other tools that don't do well with special shaders.
    Isn't it possible to just output it as a detail texture like worn edges allows me to pick a UV set, bake fake light and then apply it for the UV set as a detail texture or blend it with the original texture.

    That seems to me the most basic and universal approach to keep everything simple and compatible. If it comes at a cost in quality because the textures don't support HDR then I think that would matter not that much.
     
  6. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Well it will bake using UV0, if UV1 is not available. And you can change the asset to be a regular texture instead of a lightmap.
    Then it's up to you how to use this texture.
     
    gterveen likes this.
  7. unity_dev3194

    unity_dev3194

    Joined:
    Apr 17, 2017
    Posts:
    74
    Ran into a bug, was hoping you would know the cause:
    upload_2018-8-31_9-22-49.png

    Bakery also seems to crash when trying to bake out really large terrain. I'm exporting terrain from World Creator, and am only able to bake the terrain in chunks. Have you faced something similar, or gotten feedback about something similar?
     
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    unity_dev3194 likes this.
  9. unity_dev3194

    unity_dev3194

    Joined:
    Apr 17, 2017
    Posts:
    74
    Thanks for the prompt response. I'm unfortunately still receiving the same error. What is the proper protocol of applying the hotfix? I imported the .unitypackage without removing or altering the existing Bakery installation.
     
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    There are 3 files you need to overwrite: ftBuildGraphics.cs, ftRenderLightmap.cs and seamfixer.exe.
     
  11. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
  12. lic1227

    lic1227

    Joined:
    Jul 14, 2015
    Posts:
    41
    I have bought it yet,It's Cool and Very Fast.
    But Crashes sometimes (Tested ON 3GB VRAM) and maybe not stable engouth for large Game Project.
    Hope to include the full source code for users to customize feature or bug fixing.
     
  13. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Any error messages or clues? Anything special about the scene? Does it work with example scenes?
     
  14. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,145
    I am getting these crashes as well since the first version but not actually anything that can tell me the reason. First time crashes and next time it bakes !
     
  15. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Did you try on 1.2 though? There was a very important fix.
     
  16. zagreekie

    zagreekie

    Joined:
    Nov 20, 2017
    Posts:
    29
    This asset is so close to perfect for me, however, I seem to be getting a really strange bleeding effect which makes no sense, maybe someone here has some tips?

    upload_2018-9-1_21-15-29.png

    The light bleeding is definitely coming from the emissive shadier which is only applied on the 2 bar lights at the bottom and the small circular light at the top.

    increasing the pack margin seems to do nothing. In this example above there is literally nothing in this scene other than this one wall panel.

    If anyone has any ideas it would be a great help!

    p.s. i know in this render it has backface GI on, but i have tested it on and off and it made no difference.
     
    guycalledfrank likes this.
  17. zagreekie

    zagreekie

    Joined:
    Nov 20, 2017
    Posts:
    29
    In reference to the above, comment, here is the texture used in the emissive elements on this mesh, and on the right is i beleve the lightmap generated, it seems there are additional parts of the emissive texture in the lightmap that are not on the acual model, note the "deck 6" in the upper right of the lightmap, that is no ware on the actual 3d model yet its on the light map?

    This mesh does have multiple materials on it 5 in total I believe., could that cause a problem?
    upload_2018-9-1_21-30-18.png
     
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Interesting. If you can send me this model via PM, I'll debug.
    How big is the lightmap texture?
    Random guess: if you select the emissive texture asset, disable "Generate Mip Maps" and rebake, will bleeding disappear?
     
  19. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Totally criptic stuff for us humans but looks like you found some other devs that are at your level in there.

    managed to get an exception:
    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <f826c2584fc94ec19a48a6576640bdc5>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
    ftRenderLightmap.UpdateMaskArray (System.Int32 LMID, System.String lname, UnityEngine.Light ulht, System.Boolean denoise) (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:4289)
    ftRenderLightmap+<RenderLMDirect>c__Iterator3.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:3885)
    ftRenderLightmap+<RenderLightmapFunc>c__Iterator2.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:2466)
    ftRenderLightmap.RenderLightmapUpdate () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1923)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:191)


    I was doing some tests, first bake was veeery nice, there hwere no lightproves , I created after it, I rendered proves. THen I decided to make some hcanges and rebake, I was getting a bit odd bakes as teh emission plane seemed no longer to emit light. Not sure if the proves are involved in this, rebooted and I'm doing a bake again. Will update.
     
    guycalledfrank likes this.
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Ah, that seems simple enough to fix. Sent you a fix via PM.
     
    TooManySugar likes this.
  21. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    If you hit render light proves and you cancel hwen prompts you to save scene or not lightmaps/lighting gets destroyed, rebaking to see if I cang recover the scene.

    EDIT :Ok just received your PM so this postmay reflect fixed issue.
     
  22. zagreekie

    zagreekie

    Joined:
    Nov 20, 2017
    Posts:
    29
    Just as I was writing you my 3d artist found a solution. the mesh was a single mesh with multiple UV/material sets, by re-exporting the mesh but dividing up each material set into an individual part of the mesh, that fixed the problem.

    AS you will see below, top left, is how the original mesh was, a single mesh with 5 material/UV map areas on it, and as a test we overlayed the emission map to every single one of the materials and noticed the light bleed matched up, that's why we tried fracturing the mesh into 1 part per material, and it works perfectly now. im just leaving this here incase anyone else runs into the same problem.

    upload_2018-9-2_0-11-52.png
     
    Ruonan, Balours and guycalledfrank like this.
  23. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    The updated version seems not to crash, I've done several bakes with proves and u such without issues.

    I lit this scene with emission surfaces only (there is skylight but I think can not penetrate inside this area, I should delete.
    Rendering finished in 188,944 seconds

    upload_2018-9-2_1-5-28.png

    upload_2018-9-2_1-5-43.png

    I did not use the visual material for emision. I did duplicate and tweak emision value, this is because with the emision value I liked there was massive bloom on material.

    I hope Unity gives you an award when you complete the asset. They won´t be too happy tho cause you've basically ruined their rays lightmap thing, well if it ever delivers.
     
    macdude2 and guycalledfrank like this.
  24. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    OK saw this in teh console when baking reflection prove

    PPtr cast failed when dereferencing! Casting from OcclusionCullingSettings to Texture!
    System.Reflection.MethodBase:Invoke(Object, Object[])
    <RenderReflProbesFunc>c__Iterator0:MoveNext() (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1008)
    ftRenderLightmap:RenderReflProbesUpdate() (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:936)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Sometimes it happens when you render a probe, even via "bake" button on the probe. I don't think it has to do anything with Bakery, and it's harmless.
     
    DEEnvironment and TooManySugar like this.
  26. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Found small glitch.
    You see the buildings in teh background?, check their lightmap status, its set to none, yet, they've baked
    upload_2018-9-2_14-51-26.png

    digging a bit found their parent is set to lightmap static (empty transform)
    Some of other child of this parent are set to lightmap. Hope this helps to find the issue.
     
  27. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    This is probably not a glitch but. When using distance shadowmap so when baking shadows also on non indirect, when displaying lightmap in scene window, only indirect is shown, for example in the harbour image above only there is indirect but when displayed shaded you can also see direct shadows baked. Is there a way to display both? In Beast there was option to display hide ligthmap in editor, that would also be fine IMO.
     
  28. zagreekie

    zagreekie

    Joined:
    Nov 20, 2017
    Posts:
    29
    @guycalledfrank

    You are a god, I cannot thank you enough, this spaceship internal environment has never been able to bake properly due to how large it is and its detail, in 6 months of trying to get lightmaps to bake well it only managed to finish without crashing once, and it looked crap. with bakery it finished in under an hour, and looks like this:

    upload_2018-9-2_17-46-25.png

    I cannot thank you enough!
     
    colin299, Ruonan, macdude2 and 6 others like this.
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Hmm that's interesting. And it wasn't set when you started the bake, you didn't uncheck it after the bake, right? :D I'm not sure how can it happen, filtering code is pretty straightforward. Can you reproduce it on a simple scene?

    Hmm? If you have any masks baked, it should look like this:
    upload_2018-9-2_20-6-38.png


    Looks AMAZING! Thank you as well for showing such great screenshots!
     
  30. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I cleared lightmap data, rebaked, and keeps happening.

    I tried to reproduce using some cubes in an empty scen an ddoes not happen. I'll try to build a repro scene. I'm busy trying to make things gpu instance, for this matter, ligthmap wise using lightmap groups looks the way to go. I'm having issue with the shader as my double sided "standard" is not gpu instancing :\

    YEs I've the directional data baked
    upload_2018-9-2_20-10-59.png

    and it works fine simply does not show in lightmap view
    upload_2018-9-2_20-11-51.png
     
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Everything looks good on your screenshot. Perhaps I'm misunderstaing what "lightmap view" do you mean?

    Oh wait. You mean the scene view mode (shaded/wireframe/lightmap/etc)?... Perhaps it's expected. Did you try with Enlighten/Progressive? Shadowmasks work close with real-time lights, so lightmap scene view might be not adapted to show them.
     
  32. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Yes I meant that, I think Beast did display both indirect and direct, nevermind, just a comment.

    Checked a post from before I knew of bakery, it seems only displays indirect.
    https://forum.unity.com/threads/progressive-lightmapper.454362/page-14#post-3592184

    For GPU instancing on transparent meshes I'll duplicate mesh, invert normals and merge with the other, this is a nightmare for future updates but I just need to get it working, QUICK :D
     
  33. HenriSweco

    HenriSweco

    Joined:
    Aug 8, 2016
    Posts:
    28
    I'm not sure if I'm overlooking something obvious. I think I read somewhere that transparent/cutout(entirely) should work currently(standard shader), but no partly transparent shadows(?). I can't seem to be able to get any light into a room through windows in my model, I've tried both transparent/cutout methods in the standard shader, with 0 alpha.

    A simple scene with a fully transparent cube and regular plane and a bakery direct light. I still get the full shadow of the cube.

    I tried on 2018.1.5f1, 2018.2.6f1, and 2017.4.4f1.
     
  34. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    "For anyone interested, I published a tech writeup about GPU lightmap baking"

    Thanks for the article, was an interesting read!


    "A simple scene with a fully transparent cube and regular plane and a bakery direct light. I still get the full shadow of the cube."

    Can confirm this as well... have some buildings which are like this


    The glass is treated as 100% opaque to Bakery. Oddly, I disable the GameObject but it is still included! The glass is a child of the main building Parent.
     
  35. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    I find that after a successful bake, if I then untick "Export Geometry and Maps" then re-bake, I get this error and you need to kill the Unity process. I only changed sun light color.


    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    6. ftRenderLightmap+<RenderLMFinalize>c__Iterator4.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:4493)
    7. ftRenderLightmap+<RenderLightmapFunc>c__Iterator2.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:2736)
    8. ftRenderLightmap.RenderLightmapUpdate () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1945)
    9. UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:191)
     
  36. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    Cutout totally works. Partial transparency is not supported yet, so with semi-transparent shaders it kinda just uses the cutoff value of 0.5 instead. If your windows are less transparent that that. they will look opaque. I would just remove "Lightmapped Static" checkbox from glass objects for now.

    OK this is either a bug or you're doing something wrong. Can you make a simplre reproducible example?
     
  37. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    OK, yeah I can confirm this option is broken. You better never untick it for now. I'll try to fix it in time for the next update.
     
  38. HenriSweco

    HenriSweco

    Joined:
    Aug 8, 2016
    Posts:
    28


    Color alpha is 0. In most cases I would disable lightmapping on windows and glasses, or disable the game object entirely for baking, but sometimes I get temporary models with multi-materials and one of them is the window.
     
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    I see. Color alpha seems to be ignored. Will fix that. Texture alpha should work though.
     
  40. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    In regards to GPU instancing
    cloned a mesh and confirmed it to be instancing, its quite crazy to see it so many times with batches not raising
    I baked a lightmap for all of them using a lm group to ensure only a lm is generated and it just adds one extra drawcall to the whole scene. So I guess GPU instancing and ligthmaping can work together.

    For the harbour map, enabling instancing was not making the objects to get (instantiate) in the frame debuger so I did this script:
    https://forum.unity.com/threads/instanced-gpu-rendering-doesnt-work-reliably.419063/#post-3632905
    That is you place on teh prefab it will delete the current instance and instantiate, this way I'm gettin a bunch of theese actually gpu instanced. So I ask myself, is there a way to pass the lightmaping to the newly instantiated object before I destroy the original object¿?¿?
     
    guycalledfrank likes this.
  41. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    I'm a bit lost at what and how are you trying to accomplish, but you can copy lightmapping setup from one MeshRenderer to another by copying lightmapIndex and lightmapScaleOffset.
     
    TooManySugar likes this.
  42. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    The harbour scene Ive been posting. Has meshes that are prefabs such containers. I waht to try to GPU instance as much as I can in order to reduce drawcalls as camera render is now my major resource consumer on the ptofiler. Im hitting 40 45 fps on the xbox and need to get solid 60 withour trashing graphics further.

    Enabling gpu instancin on materials wont help instancing current prefabs as I can see on the frame debuger.

    I created an script that is attached to those prefabs that on start instantiates dame prefab is attached to and destroys original objet. This causes a more sucessfull instancing. Tbh, I would have spected this to work in a much more auto manner.
    So, some of theese prefabs are lightmaped (yes even if they are dynamic) and I whant theese newly instantiated prefabs to grab the lightmap of the original one.
     
    guycalledfrank likes this.
  43. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    LODs are coming. Now I only need to find some good models to test ;)

     
    Ruchir, Balours, Xeverian and 6 others like this.
  44. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    Hi, I am really new to lighting techniques and recently bought Bakery since my scene takes hours to render lighting.
    I'm having an issue where I try to render the lightmaps and right after I click through the prompt that says how much vram will be used I get error "Object _ExportTerrain was destroyed mid-export". When I disable "Lightmap static" on the terrain it completes rendering, but lightmaps aren't rendered for the terrain, obviously. I followed the manual pretty closely, but I just can't seem to figure it out.
    Any help would be great because, again, I haven't had much lighting experience.

     
    guycalledfrank likes this.
  45. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    That's weird and shouldn't happen. Did you use any Lightmap Group components? What is the heightmap resolution? Any special shaders on the terrain? Does it work if you put the terrain in an empty scene without everything else? If it still crashes, can you send me a .unitypackage file with it to debug?
     
  46. DebugLogError

    DebugLogError

    Joined:
    Jul 24, 2013
    Posts:
    54
    @guycalledfrank Bought the package today - love it. Quick question, maybe I'm missing something but how can I change the darkest lighting value possible (e.g. if I were to bake a scene with no light sources (or light sources with no bounces) I need the dark areas to not be pure black for my project - but rather a consistently lit "almost black" color so that objects are still distinguishable (both interior and exterior)).
     
    Last edited: Sep 4, 2018
  47. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Hello,

    Cannot bake with a Textels Per Unit > 2. Scene has about 750'000 tris, has ~20'000 objects most of which are using light probes and is about 3km^2.

    It always crashes 'generating LOD UV' . 'Cancel' button doesn't work and need to kill Unity process.

    2018-09-04 13_45_56.png
     
  48. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    There is no such option unfortunately, and it's unrealistic. You can create a Skylight to fill the scene with ambient lighting.

    Try going to advanced settings and setting "GI VRAM optimization" to "Force Off".
    What is your VRAM size?
     
  49. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Heya - another one whilst testing today. :)

    Texel Resolution appears to be 1/2 of what is actually displayed on meshes which can be confusing when seeing lower resolution maps in Bakery.

    Bakery
    Left plane = 8texels/unit
    Right plane = 1texel/unit
    2018-09-04 14_17_16.png

    Progressive
    2018-09-04 14_16_11.png
     
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,628
    The logic of "texels per unit" may differ from that of Unity. Both are approximate anyway. As for the checkerboard visualization, I'm not even sure what data it uses, but it's not linked to Bakery.