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. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666


    Asset store link:

    https://assetstore.unity.com/packages/tools/level-design/bakery-gpu-lightmapper-122218

    Link to RTPreview plugin for Bakery: https://assetstore.unity.com/packages/tools/level-design/bakery-real-time-preview-164462

    Hi everyone!
    I'm really excited to announce that I'm going to release the GPU lightmapper I was working on (for quite some time) on the asset store :)
    It's called Bakery. Because why not.
    My aim is to create a production-ready, hassle-free, flexible solution that I would like to use myself. I was rendering lightmaps all my life - in 3dsmax default scanline, in Vray, in Beast, in Enlighten and so on, and I never was fully satisfied with the results and flexibility.
    Or maybe reinventing the wheel is just my hobby.

    The focus of the project is:
    - Getting rid of all baking artifacts (seams, leaks, noise...).
    - Baking very customized lightmaps and mixing/switching them at runtime (e.g. any combination of direct/indirect/shadowmask/RNM/etc).
    - Getting physically accurate results. For that purpose I carefully compared it against Mitsuba using it as reference (fun fact: Unity's default light falloff is fake and not physically correct).
    - Getting maximum baking speed without going noticeably fake.

    The focus of the project is NOT:
    - Any kind of real-time GI. I'll leave it to others.

    Anyway, here is the list of features already implemented:
    - Global illumination.
    - Light sources: directional, sky (color and HDRI), mesh (any shape and texture), IES, spot (any cookie texture), point.
    - Materials: supports albedo, opacity and emission textures/colors.
    - Baking direct/indirect/mixed lighting.
    - Baking shadowmasks.
    - Baking ambient occlusion.
    - Supports directional baking (bump/specular) with 4 modes: dominant direction (compatible with most shaders), Radiosity Normal Mapping, per-pixel spherical harmonics, as well as simply baking normal maps to diffuse.
    - Denoising, based on Nvidia's amazing AI Denoiser.
    - Automatic fixing of UV seams on smooth surfaces and various lighting leaks.
    - Can bake lighting to 3D textures as well.
    - Baking Light Probes.
    - Automatic atlas packing + UV padding adjustment.
    - Bicubic lightmap filtering shader (can be patched to all default/custom shaders).
    - 2 lighting falloff modes: Unity-like and a realistic inverse-squared one. Also ability to patch default shaders to make Unity use inverse-square.
    - Mesh and terrain support.
    - Can also bake lighting into vertex colors.
    - Lightmapped prefabs.

    Workflow is already pretty smooth - you just add Bakery light components to lights, mark stuff Static as usual, and hit Render.
    As for baking speed, it's already quite faster than Enlighten and Progressive (at least in 5.6 and on GTX1060).

    Features to come soon:
    -̶ ̶G̶I̶ ̶f̶r̶o̶m̶ ̶c̶u̶s̶t̶o̶m̶ ̶s̶h̶a̶d̶e̶r̶s̶.̶ [Added in v1.1]
    -̶ ̶S̶h̶a̶d̶o̶w̶m̶a̶s̶k̶ ̶s̶u̶p̶p̶o̶r̶t̶.̶[Added in v1.2]
    -̶ ̶L̶O̶D̶ ̶s̶u̶p̶p̶o̶r̶t̶.̶ ̶[Added in v1.3]
    -̶ ̶D̶i̶r̶e̶c̶t̶i̶o̶n̶a̶l̶ ̶l̶i̶g̶h̶t̶m̶a̶p̶s̶ ̶s̶u̶p̶p̶o̶r̶t̶ ̶(̶b̶u̶m̶p̶,̶ ̶s̶p̶e̶c̶u̶l̶a̶r̶)̶.̶[Added in v1.4]
    -̶ ̶A̶ ̶n̶e̶w̶ ̶l̶i̶g̶h̶t̶ ̶p̶r̶o̶b̶e̶ ̶s̶y̶s̶t̶e̶m̶.̶ [Added as BakeryVolumes in v1.8]
    - Runtime switchable/blendable lightmaps support.
    - ̶̶̶P̶̶̶r̶̶̶e̶̶̶v̶̶̶i̶̶̶e̶̶̶w̶̶̶ ̶̶̶c̶̶̶a̶̶̶m̶̶̶e̶̶̶r̶̶̶a̶̶̶ ̶̶̶p̶̶̶a̶̶̶t̶̶̶h̶̶̶ ̶̶̶t̶̶̶r̶̶̶a̶̶̶c̶̶̶e̶̶̶r̶̶̶.̶̶̶ [Added as a separate asset]

    Currently it only works on Nvidia (GeForce 6xx or newer) / Windows though, because it's based on OptiX/CUDA/D3D11 code. If there will be demand, I'll look into widening the platform support.
    A̶n̶o̶t̶h̶e̶r̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶i̶s̶ ̶v̶i̶d̶e̶o̶ ̶m̶e̶m̶o̶r̶y̶ ̶u̶s̶a̶g̶e̶.̶ ̶C̶u̶r̶r̶e̶n̶t̶ ̶G̶I̶ ̶s̶o̶l̶u̶t̶i̶o̶n̶ ̶c̶a̶n̶ ̶e̶a̶t̶ ̶t̶o̶o̶ ̶m̶u̶c̶h̶ ̶m̶e̶m̶o̶r̶y̶,̶ ̶a̶n̶d̶ ̶I̶'̶m̶ ̶g̶o̶i̶n̶g̶ ̶t̶o̶ ̶d̶o̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶ ̶a̶b̶o̶u̶t̶ ̶i̶t̶.̶(fixed) Having more than 2 GB VRAM is advised (but not required, it works on 1 GB with smaller scenes).

    Here I'm just posting updates and pics. I'm also interested in what you guys think about this kind of project, what you were missing in built-in lightmappers, and what you'd like to see :)

    Documentation: https://geom.io/bakery/wiki/

    FAQ
    Q: Does it have realtime GI?
    A: No.

    Q: What about mixed lighting?
    A: Yes! Bakery supports baking indirect separately to use with real-time lights, and also baking static shadows (shadowmask) and combining them with dynamic.

    Q: I can't get shadowmask to work
    A: Check following things:
    - Bakery's Render Mode is set to Shadowmask
    - Masked lights have both Unity and Bakery light components on them.
    - Masked Bakery light components have "shadowmask" checkbox enabled on them.

    Q: I rendered shadowmasks, but all shadows are dynamic
    A: You're in Distance Shadowmask mode, it's expected
    - Read about the difference:
    https://docs.unity3d.com/Manual/LightMode-Mixed-Shadowmask.html
    https://docs.unity3d.com/Manual/LightMode-Mixed-DistanceShadowmask.html
    - To switch between two modes, you can use "Distance Shadowmask" checkbox in Bakery main window.
    - If you're on 5.6, go to Window->Lighting->Mixed Lighting->Lighting Mode to switch the mode.

    Q: What about bump/specular in shadowed areas?
    A: Yep, use directional lightmaps for that. Setting "Directional Mode" to "Dominant Direction" would be the most straightforward way, but also read the manual about other modes (RNM and SH) and check the example scenes to see what's best for you :)

    Q: How do I make a lightmapped prefab?
    A: Use the Lightmapped Prefab component.

    Q: How do I use git/collab/other version control system with Bakery?
    A: Since v1.45 it should Just Work. However, if you are using Unity 5.x, you might need a few extra steps. Also you don't need to commit Bakery folders, only your own project files. Refer to the manual for details.

    Q: How do I bake using my own UVs without any alterations to them?
    A: Read about Lightmap Groups in the manual.

    Q: Which platforms are supported?
    A: You can ship games with Bakery lightmaps on any platform. But for using Bakery you will need a 64-bit Windows (7+) machine with a Nvidia (6xx or newer) card.

    Q: Is it progressive? Does it show lightmap updates in real time?
    A: No. Just a progress bar.

    Q: How do I share a scene with someone who doesn’t have Bakery installed?
    A: Apart from the scene and its lightmaps you also have to include a few scripts, namely:
    - ftLightmaps.cs
    - ftLightmapsStorage.cs
    - ftLocalStorage.cs
    - ftGlobalStorage.cs
    - ftModelPostProcessor.cs

    Q: Denoiser throws error 505.
    A: Update the drivers.

    fdlm.jpg ftareafixed.jpg ftprobes.jpg texarea.jpg image_2018-06-06_00-18-19.jpg
     
    Last edited: Nov 25, 2020
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    IES lights example:

    fties.jpg
     
  3. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    453
    Wow. Can't wait to use it!
    Great work !

    There is the possibility to join the beta?
     
  4. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    "Render selected" button, as well as only re-baking certain lights."
    Yes please!

    Can´t wait for it!
     
    Last edited: Jun 14, 2018
    TooManySugar and guycalledfrank like this.
  5. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    Both my current projects use realt-time GI for now, and we do the same at work, but I'm willing to test most things at work so we'll most likely be purchasing this, because it looks great!

    My main question is, how is one person able to do what several large corporations have failed to? Are you a genius? :)
     
  6. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    630
    Fantastic idea, count me as a sale!!!
     
    guycalledfrank likes this.
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Thanks everyone!

    Well, it's almost done. I'm thinking of releasing the beta for a cheaper price (think early access) and then improving it over time with final version being more expensive.

    I should mention that at the moment it doesn't render exactly only selected objects. It renders texture atlases to which selected objects belong. But other atlases are not updated.
    Also I didn't mention, but I have a special component to manually put objects into their own named lightmaps, if automatic atlases don't suit you or when you want to switch lightmaps on certain objects. When you actually use it, current Render Selected is more useful.
    I will eventually update this feature to only update parts of atlases.

    Also, other limitations of the current version (which I'm going to fix though):
    - //No Terrain support yet. [EDIT: terrain support was implemented]
    - No SpeedTree support yet.
    - No customized shader albedo/alpha/emission support yet. Color/alpha/emission are taken directly from material's colors/textures (using the same naming convention Standard shader uses).

    Too much free time.
     
    Last edited: Jun 15, 2018
    lolaswift, tntfoz, atomicjoe and 2 others like this.
  8. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Great!
    (Never understood why Unity didn´t so...)
     
  9. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    By the way, here is the current state of UI:
     

    Attached Files:

    Mark_01 likes this.
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Terrain support was easier than I thought, finished in a day :)
     

    Attached Files:

  11. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    hello,
    Can support with asset bundle?
     
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    nice! can't use it yet as I'm on a mac, but watching where this goes! very well done!
     
    guycalledfrank likes this.
  13. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Good point, didn't test that yet. Will see if it works.
     
    Mark_01 likes this.
  14. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    389
    And its compatible with U5.6, i guess :)
     
  15. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Thanks
     
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Yes. I'm working on 5.6 myself. Also testing it on latest 2018.
     
    Mark_01 likes this.
  17. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    630
    I think a fair amount might end up with the 2017.4 LTS versions too.

    For sure if you can make it work with 5.6 2017 and 2018 obviously the best :)

    I don't have the numbers but i would assume the majority are 2017.4

    Am very excited about this! I have a feeling this can make you lots of $$$!
     
    Neviah and guycalledfrank like this.
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Here are some pics of the automatic UV seam fixer results:


    uvfix.jpg uvfix2.jpg photo_2018-06-11_14-12-56.jpg
     
  19. hugopok

    hugopok

    Joined:
    Mar 30, 2016
    Posts:
    46
    Hi, I am working on a game where a house is generated at runtime, and I was look for something like this to bake my scene and improve the performance. If you need a tester or any kind of help, please contact me. I will be very happy to contribute to your project
     
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Hi hugopok. If it's generated at runtime, high quality lightmapping won't work. It still takes from a few seconds to several minutes to bake a scene (depending on complexity), and my particular solution also requires specific Nvidia hardware. So it's not really a good idea to run it on a player's machine, it's more about using it by devs for static maps.
     
    Mark_01 likes this.
  21. hugopok

    hugopok

    Joined:
    Mar 30, 2016
    Posts:
    46
    O
    Ok i understand , thank you for your reply. I Will search There is a runtime lightmapper or maybe a Will create myself , anyway thank you for your time :)
     
  22. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    If you don't need global illumination, it's certainly possible to create a runtime lightmapper with decent speed (done that - created this a few years ago). All you need is to basically rasterize the geometry using UVs as position and calculate lighting in the pixel shader.
     
    Mark_01 likes this.
  23. mycroftx

    mycroftx

    Joined:
    Aug 11, 2012
    Posts:
    4
    Oh count me in! As soon as "early access" is ready i want to support you. Even for prototype work this will shed hours of some projects I bet.
     
    Last edited: Jun 19, 2018
    guycalledfrank likes this.
  24. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    In case you're wondering, I'm still finishing this project, mainly fixing bugs and reducing memory usage. Here are some more pics (scenes from testers and some emissive surfaces):


    lphoto_2018-06-04_12-27-09.jpg photo_2018-06-14_14-29-45.jpg ftemissive.jpg ftemissive2.jpg
     
    Gametyme, Mark_01 and Detniess like this.
  25. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Awesome. Have you considered using RadeonRays in order to support any hardware and not only nVidia ?
    In fact dlls are already inside the Unity 2018.2 b9 installation !

    Great work however !
     
  26. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Any chance to record a video and share it and tell us your GPU model !?
     
  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Thanks. I do consider that, but I started working on it before RadeonRays existed. Nvidia's Optix was the only library, later AMD released FireRays (now renamed to RadeonRays it seems), then DXR...

    Definitely preparing a video for the initial release :)
     
  28. Stereo_Image

    Stereo_Image

    Joined:
    Jan 25, 2017
    Posts:
    8
    Looks Great! What is your ETA on the release Weeks? Months?
     
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    I aim to release it by the end of this month, so stay tuned. I could improve it for a few more months, but overall all major problems are solved, and it's pretty usable.
     
    Mark_01, Stereo_Image and Neviah like this.
  30. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Meanwhile, trying to come up with some tricks to enable lightmap mipmapping. As you may know, you can't enable mipmapping on lightmaps (or simply downscale them), because things start to leak over each other.
    Most importantly I'm doing this because GI calculation depends on previously computed lightmaps (that's a natural way to cache lighting in a lightmapper), and because of that, GI can eat VRAM quite a bit. So my idea is to solve it via adaptively LODing cached lighting this way.
     

    Attached Files:

    Mark_01 likes this.
  31. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    630

    GPU lightmapper very much starting to look like an insta buy for I would guess many many people. ( and really is very needed ) .. I see really great things for you in the future. Lots of assets have been on the store and selling for years and years .. ( playmaker )

    Thank you for all the hard work you are putting in before release. As a Canadian I'd say I'm " stoked " :)
     
    guycalledfrank likes this.
  32. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    OK, the big VRAM optimization is done. It should now be possible to fit rather huge scenes into memory. Now give me a few days to fix all the tiny annoying problems :D
     
    Vagabond_ likes this.
  33. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Tried baking the city from my old unfinished game. Took 8 minutes to bake. 2x4096x4096 + 1x2048x2048, 5 GI bounces :)

    fttest6.png
     
  34. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    GPU specs please :)
     
  35. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    GTX1060 6GB
     
    Vagabond_ likes this.
  36. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I did not move my project because Beast could handle big urban areas and Enlighten did not. I've a GTX1080 and I could test on my scenes. I've already ported one to 2018.2.

    Definitelly looking for the features listed under "Features to come soon:"

    I could test the pluging if you whant.
     
  37. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    You could release a demo versio nthat watermarks the lightmaps and has a maximun resolion and lightmap number or something like that
     
  38. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    I should really release the early access version in a couple of days already.

    Here are some more screenshots from the same scene - and with some textures removed to show the lightmap:

    (forgot to mark lamp materials emissive, so they don't affect lighting though...)

    photo_2018-06-30_21-30-55.jpg photo_2018-06-30_21-21-29.jpg photo_2018-06-30_21-31-53.jpg photo_2018-06-30_21-33-57 (2).jpg
     
  39. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    cool, some edges in sedond shot seem to lack AO like obscuring.
    In the third, when that wood barrier meets ground there are some artifacts, may be is not touching ground.
    I asume the character in firs photo is non static and thus no shadow around. But AO edge also in last shot when that wardrove meet floor edge feels too clean. But overall is cool!
     
  40. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    sorry, didn't get this one

    right, there's just not enough resolution for shadow in the lightmap to be accurately connected to the barrier.

    yeah, he's dynamic
    Well it should be clean. Global illumination never just darkens every corner like AO does. AO is just a cheap approximation of GI you throw on screen when you don't have time/resources to compute proper GI. AO usually ignores inter-reflections and large-scale effects.
     
    AcidArrow and Mark_01 like this.
  41. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I see, yet Beast had AO. Still AO can be added in post.
     
  42. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    AO is also nice to bake, especially for mobile
     
  43. Osher

    Osher

    Joined:
    Feb 6, 2014
    Posts:
    11
    Very interesting stuff are working on, it's a sure buy so can't wait to test it out. Was wondering if it works in progressive mode as Redshift, Octane etc and if it is based on Nvidia Optix with all the benefits that technology brings along?
     
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    It's not progressive. Not even a path tracer. It uses raytracing but in a different way. Optix is just a library that implements ray-primitive intersection on a GPU, and it does it really fast. Everything else is up to developer. Neural net GPU Denoiser core is also a part of Optix, and so far I've never seen better denoising.
     
  45. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Today I tried to record a video comparison of baking speed using Sponza as example. It didn't go well though:
    (20 texels per unit)
    - Bakery: 200 seconds.
    - Enlighten: more than 1 hour, I went out of disk space recording the video.
    - Progressive (2018.1.2): just gets stuck infinitely in "Baking" (??). Just shows a very low-resolution lightmap all the time (like, 1 texel per 4 meters). Doesn't seem to update it.
    - Progressive (5.6): just crashes the whole editor. Woah.
    Maybe there is something wrong about the scene so built-in lightmappers don't like it. But it's literally 1 FBX with pre-made UVs and direct+sky lights.

    Anyway: I'm ready to publish. Would you like to wait a bit more while I'm trying to create a proper video, or should I just release it already anyway?
     
    Last edited: Jul 4, 2018
  46. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    630
    Unity is taking a month to okay new assets, I have heard.
     
    guycalledfrank likes this.
  47. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Definitely submit as soon as you can, it takes them ages to approve stuff. Plenty of time to get a nice video made while you wait.
     
    guycalledfrank likes this.
  48. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Oh, didn't realize that. Alright, publishing now :)
     
    Mark_01 likes this.
  49. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Looking forward to see it.
    Does it support runtime baking?
     
    guycalledfrank likes this.
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    If you mean rendering during the game, then no. Lightmaps need to be baked by the developer before the game build is created.
     
    Neviah likes this.