Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Bakery - GPU Lightmapper (v1.3) [RELEASED]

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

  1. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356


    Asset store link:
    https://www.assetstore.unity3d.com/en/#!/content/122218

    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.
    - Denoising, based on Nvidia's amazing AI Denoiser.
    - Automatic fixing of UV seams on smooth surfaces and various lighting leaks.
    - "Render selected" button, as well as only re-baking certain lights.
    - 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.

    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]
    - Directional lightmaps support (bump, specular).
    - Runtime switchable/blendable lightmaps support.

    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://docs.google.com/document/d/19ZDUAVJA69YHLMMCzc3FOneTM5IfEGeiLd7P_qYfJ9c/edit

    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: Directional lightmaps are on the way and should be available in the next release.
    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.

    - fdlm.jpg ftareafixed.jpg ftprobes.jpg texarea.jpg image_2018-06-06_00-18-19.jpg
     
    Last edited: Sep 19, 2018 at 8:08 PM
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356
    IES lights example:

    fties.jpg
     
    lostframe, Gametyme, red2blue and 2 others like this.
  3. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    275
    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,011
    "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:
    148
    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:
    299
    Fantastic idea, count me as a sale!!!
     
    guycalledfrank likes this.
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356
    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
    atomicjoe, Cascho01 and Mark_01 like this.
  8. Cascho01

    Cascho01

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

    guycalledfrank

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

    Attached Files:

    Mark_01 likes this.
  10. guycalledfrank

    guycalledfrank

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

    Attached Files:

  11. 3d_Artist1987

    3d_Artist1987

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

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,612
    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:
    356
    Good point, didn't test that yet. Will see if it works.
     
    Mark_01 likes this.
  14. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    321
    And its compatible with U5.6, i guess :)
     
  15. 3d_Artist1987

    3d_Artist1987

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

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356
    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:
    299
    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:
    356
    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:
    30
    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:
    356
    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:
    30
    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:
    356
    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:
    356
    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:
    621
    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:
    621
    Any chance to record a video and share it and tell us your GPU model !?
     
  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356
    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:
    356
    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:
    356
    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:
    299

    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:
    356
    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:
    356
    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:
    621
    GPU specs please :)
     
  35. guycalledfrank

    guycalledfrank

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

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    819
    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:
    819
    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:
    356
    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:
    819
    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:
    356
    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:
    819
    I see, yet Beast had AO. Still AO can be added in post.
     
  42. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,612
    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:
    356
    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:
    356
    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:
    299
    Unity is taking a month to okay new assets, I have heard.
     
    guycalledfrank likes this.
  47. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    335
    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:
    356
    Oh, didn't realize that. Alright, publishing now :)
     
    Mark_01 likes this.
  49. Cascho01

    Cascho01

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

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    356
    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.