Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    @guycalledfrank I did a shader to use with graphics.blit that dilates a texture after it has been rendered. Each pass dilates a single pixel around, but it's very fast so you can just make a lot of passes and it will never overwrite any pixel. I made it for a custom mesh and texture baker. It works perfectly. Let me know if you want it :)
     
    guycalledfrank likes this.
  2. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    fyi

    on my lightmap journey i found this handy project.
    Performs pretty solid in actual 2018.3x releases.

    https://github.com/guiglass/Lighting-Scenario-Switcher/blob/master/README.md

    It allows to switch
    Lightmaps, Lightprobes, Real-Time Lights, Lens Flares And Materials From Pre-Saved Profiles by generating UID s.

    Everything is saved in an seperate switchable Lighting Scenario Folder.

    There is also a nice video.










     
    Last edited: Feb 21, 2019
    guycalledfrank and atomicjoe like this.
  3. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    This seems amazing! It's from 2 years ago though. Have you tried it with Unity 2018.3?
    LOTS of things broke in the last 2 years of Unity releases...
     
  4. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Works great and gave me a big ahaaaaa moment by crossing the code.
    Tested the cube demo by rebaking and adding other scenarios in 2018.3.6f1.

    I think there was an little compile error due to an Unity.Editor change. I can check tomorrow.
     
    Last edited: Feb 21, 2019
    atomicjoe likes this.
  5. Loards

    Loards

    Joined:
    May 2, 2013
    Posts:
    112
    Hi! i been having a couple of error for a while and the update didn't fix those, one is baking the Light Probes, i always get this: upload_2019-2-21_17-8-30.png

    Then, if i bake the light probes with the occlusion probes active, then the light probes are baked BUT when i close and restart unity, the light probes are gone again. i have no idea why this is happening. right now im in unity 2018.3..6f1 but i tested in older versions and was the same.

    thanks in advance for any help.
     
  6. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    We are noticing some inconsistencies with our lightmaps in the latest version of Bakery on Unity 2018.2.20
    When we reload unity, the lightmap intensity will vary so it's impossible for us to do consistent lighting

    For instance, here is a prefab saved in a scene with bakery lightmaps (lightmaps stored in the prefab, not in the scene).

    Before reloading unity:


    After reloading unity:


    Any ideas what might be causing it?

    Thanks!
     
  7. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    Definitely, thank you, really need it.
    -edit. haha misunderstood, may you send me a copy if possible, so I may learn as well.
     
    Last edited: Feb 22, 2019
    atomicjoe likes this.
  8. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    After taking a further look at my problem, I realised that my problem is about how to activate backface GI only for part of my gameobjets, which already been brought up before I noticed.
     
    atomicjoe likes this.
  9. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    hi,
    So I am using the vertex light map feature, but since Wednesday the vertex lit objects in my scene are getting screwed.
    upload_2019-2-22_15-36-40.png
    (Ignore the glow, that's the bloom Image effect).
    But basically the vertices in the mesh get all fuc*ed. the prefab itself is intact.
    Also, I pushed the scene to my branch to git and pulled it onto another pc which did not had bakery installed, and the corrupted meshes/scene came out fine on this machine, however they got broken again when I installed bakery there.
    Everything else seems to work fine . so any idea what's wrong here?
    the screenshot is from a recent iteration of the scne, the older scenes have all the vertex lightmapped objects screwed.
    unity 2018.2
    every object has the same light map group.
     
  10. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Hi @guycalledfrank , just a quick question regarding your RTX updates: do you have a planned ETA for when you'll be updating the Unity store version with them? Thanks! :)
     
  11. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Maybe you know already, but if you buy Bakery you can get access to a private repository with the latest Bakery update by the hour.
     
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    just edit

    LSS_FrontEndBase.cs(186)

    Code (CSharp):
    1. EditorUtility.CompressTexture (newTexture, texture.format, TextureCompressionQuality.Best);
    to
    Code (CSharp):
    1. EditorUtility.CompressTexture (newTexture, texture.format, UnityEditor.TextureCompressionQuality.Best);
    to run it in Unity 2018.3.6f1.
     
    atomicjoe likes this.
  13. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    Hello,

    could you please tell me which version of Unity 2018.3 is supported? I had to update to Unity 2018.3.6f1 and when I am baking scene lightmaps they are ok in the editor but on Android (OculusGO), they are broken - are you able to help me with that? (I have recalculated the scenes twice already)

    It works fine on unity 2018.2.f19 but I had to update to 2018.3 almost just before releasing new game version and now I am stuck.

    Hope to hear from you soon.

    ps. Can you tell me how to acess to private repo?

    Thanks,
    Sebastian
     
    Last edited: Feb 22, 2019
  14. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Hey @atomicjoe - I've already bought bakery, but like keeping my project in line with asset updates on the store as it's easier (lazier!) to manage! :)
     
  15. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Sorry for a radio silence for the last ~3 days - I got sick and was mostly lying in the bed, buuut much better now. So...

    I've just noticed you only had 2 GI samples. Try using at least 16.

    Yes. I also have two PCs and it seems not a huge problem to implement it.

    It should be. The dilation is limited to something like 16 pixels though, and then the denoiser comes in and can mess the most distant edges. Can you try if it works fine without the Denoise option?

    Bakery does exactly that already ;)

    This is nice! The static batching problem seem familiar and should be avoidable.

    Did you bake the lightmaps for the same scene before the probes? ... does it work if you do?

    - Any console errors during the bake?
    - Make sure you have the same Lighting Data Asset active in the scene after the bake and after restarting. It's possible some third party asset resets it (?)

    Engine quirkiness? Not sure really. What happened to your bundle workflow? :)
    Needs more info on:
    - Baking mode (full/indirect/shadowmask)
    - Directional mode.
    - Shaders.
    - ??

    No such option at the moment - will be added in the future.

    Could it be that your mesh was somehow changed on Wednesday? Maybe you (or someone else) modified it and reimported? Vertex lighting needs to be rebaked if vertices were reordered or their count changed.

    Next week? :rolleyes: Let's try that.

    Yes, but currently, it's only the C# (+ shaders) part. The core part is not hosted anywhere yet... it probably should be.

    The last one I tested with was 2013.3.3. Are they releasing them every week now? :eek:

    How exactly?

    Just send me a PM with your invoice number + github username.
     
    tntfoz and Mark_01 like this.
  16. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
     
  17. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Don't die on us just now Frank, we need you to keep updating Bakery. :p
     
    b4th, tntfoz and guycalledfrank like this.
  18. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Haha no worries, we are still using that at runtime - this is at design time only!

    My artist says that we are using:
    Full Lighting baking mode
    RNM directional mode
    Only Bakery shaders
     
  19. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Batching was a problem in v1.0, but stopped being since. As far as I remember the key was to apply lightmaps in Awake(), as it (seemingly) called before the batches are assembled. If you can make an example project that gets broken UVs in the build and send it to me, that'd be very helpful.

    Thanks, I'm trying :)

    Hmmm... nothing especially unusual. I can't really see why it happens here.
    What I know is that Unity has some constants it uses to unpack HDR lightmaps (unity_Lightmap_HDR). Maybe they are somehow reset after you reopen Unity? I dunno why I didn't get this bug then.
    Is prefab baked in the same scene it's placed? Was the scene saved before closing?
     
    atomicjoe and Mark_01 like this.
  20. jxxxxst

    jxxxxst

    Joined:
    Nov 3, 2012
    Posts:
    50
    Hi there,
    is there an easy way to keep lightprobe data in a lightmapped prefab?
     
  21. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Unfortunately no - Unity doesn't support combining multiple sets of light probes, they are basically global.
     
  22. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    So it turns out that the issue might be that lightmap encoding (unity setting) got set to medium, which broke all bakes that were done after it changed - we changed it back to high and are investigating if this fixes it

    EDIT: Nope, it seems that didn't fix it

    To answer your questions - it doesn't seem to matter which scene the prefab is baked in, and the scene does get saved before restarting
     
  23. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    @guycalledfrank
    Hi, I wonder if the dilation color could be closest pixel color?
    It should be. The dilation is limited to something like 16 pixels though, and then the denoiser comes in and can mess the most distant edges. Can you try if it works fine without the Denoise option?

    Yeah, dilation actually works fine, the problem was caused by unwanted backface GI. I need backface GI for trees but not for rocks, rocks intersecting with each other would end in a whiter color at the intersecting part. So what I do now is narrowing down the global backface GI intensity, looking for a balance I can accept.
    It would be best if we could use a keyword or some feature to turn on backface GI for different materials. Hope this feature may come in the following version.
     
  24. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    Hello @guycalledfrank I have switched to 2018.3.3 but the problem is still there :/ I have tried to rebuild the lightmap, check/uncheck split by scene etc but always after making the build on Android scene is broken (both the same in build and in editor).As you can see the Bakery settings back to defaul after the build too. Checking/unchecking "show checker" fix the problem or reloading the scene (settings are back to normal too then).

    I am attaching the screenshot before the build and after the build. I hope you can give me some tip on how I can fix it.

    Thanks,
    Sebastian
     
  25. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    \Assets\Editor\x64\Bakery\alphabuffergen.dll kills UWP packaging because it fails the AppContainerCheck.
    I think this dll must be marked "editor" only.
     
    guycalledfrank likes this.
  26. r_chevallier

    r_chevallier

    Joined:
    Apr 20, 2014
    Posts:
    31
    Hello,
    Hope you are feeling better. Your personal health is always more important than anything else.

    I posted in the past regarding UV mishaps when using "Render Selected Groups". I understand that this feature is prone to messing up other UV's previously baked. With that being said it is still a useful feature for doing "test" bakes. Many times I bake a scene and readjust the lights to make it better. I hate to have to re-bake my entire scene if I just want to see a certain section. Time-wise it takes 8 minutes for my entire scene vs 2-3 minutes when I use "Render Selected Groups".

    Recently my bakes have been failing and I have been getting errors when using "Render Selected Groups".

    ftrace error: Can't read lightmap for GI. See ftracelog.txt for details. (1001)


    Would it be helpful if I emailed you the ftracelog.txt?

    --------

    Question 2 - I thinks this has been asked already. Is it possible to add a feature to Bakery that isolates baking a certain part of the scene only (for testing purpose only and for faster bake times) without having to use "Render Selected Groups".

    Thanks for any help.
     
    Last edited: Feb 24, 2019
    guycalledfrank likes this.
  27. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    You can find ftracelog.txt in the directory
    YourProject\Assets\Editor\x64\Bakery
     
  28. r_chevallier

    r_chevallier

    Joined:
    Apr 20, 2014
    Posts:
    31
    Thanks, found it. Not sure why it doesn't show up when using Unity's search in Project tab.
     
  29. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,268
    Will this work with HX volumetric lighting
     
  30. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    That's not what Japanese animation taught me! :D
     
  31. jxxxxst

    jxxxxst

    Joined:
    Nov 3, 2012
    Posts:
    50
    Ah bummer.
    I am running into an issue where when I create lightprobes in another scene, lightmapped prefabs lose their already baked lighting. Lightprobes are part of those prefabs, perhaps if I take them out, those prefabs wont break. Will test tomorrow.
     
  32. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Does it also happen if you try building in on PC (that way I could at least verify/test it) or JUST the Android?

    Ah snap. Yes it should be editor-only, sorry. Won't happen in the next update.

    After you baked the scene normally and just moving the lights, you can also uncheck these toggles in experimental settings:

    upload_2019-2-25_14-26-51.png

    This way you can skip a lot of steps when re-rendering! Just make sure you're doing it with the last scene you baked completely.

    The log alone won't tell much in this case, but if you have any scene where it can be reproduced, that would help.

    For testing purposes you can paste a part into another scene I guess?

    Does it work with regular lightmapped lighting? If it does, then yes, it should.

    Light probe group components only supply positions for Unity/Bakery, but actual lighting is saved into Lighting Data Assets, and it's not possible to merge multiple of these. In fact there is no API to alter this asset at all (except indirectly changing existing probe colors).
     
  33. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    @guycalledfrank Can't test it on PC right now :/ Can you give me a tip how to load bakery lightmaps via c# code ? Or how to reinitialize atlasing via c# ? Something that I can try to fix the problem via C#.

    thanks
     
  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    There are 3 processes involved regarding final lightmap UV mapping:

    - Model unwrapping is done before rendering, only if you have "Adjust UV padding" option enabled, and only for models with "Generate lightmapping UVs". Bakery can reunwrap models to optimize padding between UV charts. The unwrapping instructions are also stored in models' .meta files. If you synchronize the project over multiple machines, make sure the meta files are commited, and ftGlobalStorage.asset/ftLocalStorage.asset are not. If syncing was done incorrectly, other machine can have differently unwrapped model.

    - Atlasing happens before rendering and sorts objects into different lightmaps. This results in lightmap IDs and scales/offsets generated and saved permanently for each renderer.

    - Applying the lightmaps happens in ftLightmaps.cs using the saved data from ftLightmapsStorage script being on the invisible "!ftraceLightmaps" scene object. It simply loops over the list of renderers/IDs/scales/offsets and assigns them. This is necessary, as there is no way to permanently save lightmap->renderer link in the engine since 5.0.

    ... also can you try disabling static batching in project settings and making an Android build again? It SHOULD work WITH static batching, but I wonder if something is different in your case.
     
  35. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    @guycalledfrank I will try these steps.
    In the meantime, I have checked the project on 2018.2.19 (old version I can't use) and I see that if I have selected "Progressive Lightmapper" chosen - then it breaks the lightmaps exactly like in 2018.3.3. I have tried to change Progressive to Enlighten (on 2018.3.3) but unfortunately, the lightmaps are still broken. Is it possible that Unity ignores Enlighten settings and broke the Bakery lightmap anyway?
     
  36. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    46
    since the latest update the bakery window is lagging, especially the resolution slider etc.
    The baking also fails after a certain percentage.
    The previous version with the same settings baked just fine.

    I then updated unity to the latest version but nothing changed
     

    Attached Files:

  37. BenWoodford

    BenWoodford

    Joined:
    Sep 29, 2013
    Posts:
    116
    Awesome! Ideally in a way that doesn’t require Unity on the other PC would be nice - don’t know if that is even possible mind you. The lack of editor activations we get as legit customers is a massive pain for any kind of automation like build bots, etc
     
  38. Loards

    Loards

    Joined:
    May 2, 2013
    Posts:
    112
    Yes, i always bake the lighting before the probes, no mater what combination i do, the result is the same, with the error.

    About the problem with the probes losing the baked info on
    restart, i noticed that the info lost is only the one from the ambient light/skydome light, the indirect light from other sources remain in the probes.

    Thanks.
     
  39. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    @guycalledfrank , Hi I think the issue (corrupted meshes) has something to do with github. Because now the bake itself is showing wierd stuff, it looks fine in editor mode, but pressing the play button screws the uvs up somehow (not the mesh this time, just the lightmap-uvs).
    This is on a coleague's pc (the dev), he baked the lighting on his own pc after getting the scene file from me via github.
    And we are also using additive scene loading, but the other scene only has gameplay managers and nothing else, so that's probably not the problem.
    Any idea what can be going wrong here? Because this causing a serious issue in development here , where we will have to rebuild lighting on everyone's pc .
     
    Last edited: Feb 26, 2019
  40. DarkMasster

    DarkMasster

    Joined:
    Mar 23, 2015
    Posts:
    15
    Hi ! I have two scenes ( Scene1, Scene2 ) and tow prefabs ( Prefab1, Prefab2 - both use same elements, modular assets ), in result i get issue:
    1. In Scene1 i bake lightmap in Prefab1, use BakeryLightmappedPrefab. Get correct result.
    2. Then in Scene2 i bake lightmap in Prefab2, use BakeryLightmappedPrefab. Get correct result.
    3. But when i open new scene and drop both Prefab1+Prefab2. Lightmap in Prefab1 is BROKEN, Prefab2 - correct.
    Any one know what i do wrong ?
     
  41. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    112
    Try Disable Adjust UV Padding.
    upload_2019-2-26_14-18-22.png
     
  42. Ermask

    Ermask

    Joined:
    May 7, 2015
    Posts:
    10
    I needed more than 32 samples. But now the result is almost perfect. Thanks a lot for your help.
     
    guycalledfrank likes this.
  43. DarkMasster

    DarkMasster

    Joined:
    Mar 23, 2015
    Posts:
    15
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Does it happen instantly after you switch the lightmapper in Unity lighting window? Do you maybe have "auto generate" on? I can't see any other explanation. Without auto-generate this settings does nothing.

    I don't think it has anything to do with the update, can be an old issue. Grab the script from this post and try "Clear useless data".

    Either you don't have enough disk space, or a bug with GI VRAM optimization (try setting it to Force off).

    This exact issue and all possible workarounds are listed in FAQ (in the manual).
     
  45. r_chevallier

    r_chevallier

    Joined:
    Apr 20, 2014
    Posts:
    31
    Hello,

    I have only used Bakery for Directional and Point Lights with good results. I want to add a spot light but can't seem to find a Bakery Spot Light script?

    Thanks,
     
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Spot lights are created using Bakery Point Light (because spotlight is basically a point light with additional masking). You can add a realtime spot light and use "match to realtime" button. Or you can manually set Projection Mask to Cookie and insert the cookie texture (the one representing classic round Unity-like angle distribution is included in Bakery and called ftUnitySpotTexture).
     
  47. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    259
    Hi Frank,

    Bakery produces very nice visual results and the quality of it is great.

    That being said I was wondering if you had any tips on how to improve the performance on large maps?

    Our map is 5km by 5km, has a single terrain object, and small towns (that are each stored in there own scene) spread out around the map. Vegetation is spawned procedurally at run time and is not included in the bakes. We are using baked indirect mixed lighting.

    The workstation used for all lightmap baking has the following specs: Ryzen 5 1600 overclocked to 3.85GHz, Nvidia GTX 1080 with newest drivers, 16 GB DDR4 RAM, SSD, Windows 10 Pro 64-bit.

    Bakery takes approximately 2 hours 30 minutes (texel values of 1 to 10 don't seem to effect the time to bake, max resolution of 2048, baked indirect mode, tile size of 4096, split by scene enabled).

    Are there any optimizations I can make to the scene to make computing with Bakery faster?

    Thanks.
     
    guycalledfrank likes this.
  48. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    That already pretty fast to bake the cake of this size.
    Think second GPU brings you another 80%.
    I use 4x Titans (Pascal) and they gives me around 350%.
    But don t tested raytraced Terrains much in scale.
     
    Last edited: Feb 26, 2019
  49. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    259
    Don't get me wrong. 2 hours and 30 minutes is a great bake time compared to the Progressive CPU (~40 hours), I am just curious if there are any settings / techniques for improving bake time more so.
     
  50. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hey,
    short question. Out of your experience. Would it be possible to do this?

    Bake lighting to vertex color for large number of gpu instances e.g grass, trees...?

    Happy Hypothesis.
    With GPU Instancer we can ...

    jump to
    How can I Setup my Instances to have Material Variations on them?
    on
    https://wiki.gurbu.com/index.php?title=GPU_Instancer:FAQ


    ...setup instance based material variations by defining a buffer, register this buffer to the GPUI prototype instances (and the Prefab Manager) and modify your shader to accept this buffer. The contents of the buffer (variations) can then be set and updated during runtime...

    By baking vertex lightmap to this buffer. Don t know how for now.]
    ... it should be applieyable to the e.g gras instances as variation?
     
    Last edited: Feb 26, 2019