Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

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

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

  1. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    925
    In general it's possible. I did it with my GPU light mapper ( which is in development with its fate not yet clear ),
    and i ran it in builds. So it is possible. If you manage to add that feature your customers will be very happy :)

    Or may be it is the Optix library that does not allow it !?
     
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Well, exactly. It requires a relatively modern nvidia card, and you can't demand it from players. I'm gonna look into porting it on DXR, so it works on all cards. This is definitely possible with lighting calculations, but reimplementing the denoiser would be much trickier though.
     
  3. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    925
    Makes sense :)

    One question - what is the lowest ( average ) samples count which is considered enough for the denoiser to clean up lightmaps !?
     
  4. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    I have separate sample count per each light and one for GI. How much denoising is needed depends a lot on the scene. Open exterior scenes produce less noise in the first place, whereas interiors and generally places that catch less light require more denoising.
    Sponza is actually a hard case, because it's mostly lit by indirect light, so here is a comparison:

    ftq.jpg


    It doesn't go below 20 seconds, because there is also some constant overhead of exporting/importing/preparing stuff that doesn't depend on samples.
     
    Last edited: Jul 5, 2018
  5. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    925
    Well that's normal - but we don want it real time : ) As i can see Sponza can be baked in a minute !

    And the denoiser actually runs at the same time with the baker and not as a post processing step like the filtering in Unity PLM !?
     
  6. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Denoising is a post-processing step, that's correct.
     
    Mark_01 and Vagabond_ like this.
  7. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    300
    Nvidia only and windows only make it a no-go x2 for me, but good luck with the project.
     
    guycalledfrank likes this.
  8. Osher

    Osher

    Joined:
    Feb 6, 2014
    Posts:
    11
    Impressive to see how little difference there is between 1024 / 256 samples and 256 / 64, at least in a textured scene. Regarding the Nvidia denoiser it`s an clever piece of software, the same denoiser is used in Redshift and it does a really good job cleaning up the noise from low samples but unfortunate it sometimes results in loss of small texture details. As for denoising lightmaps I guess that should not be of any problem, just the benefits of the speed gain. Looking forward to see a video of this lightmapper in action, and of course get a chance to play around with it when it finally arrives in asset store.
     
    guycalledfrank likes this.
  9. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    I'm preparing some example scenes to be included in the final lightmapper package. Is there something specific you guys would like to see there?
    I think there should be at least one scene with all light types, and one scene with something Sponza-like, although the real Sponza scene takes more than the lightmapper itself, so maybe I should simplify it or find something else.
     
  10. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I'm curious to know how well your lightmapper works with Unity's built-in lightmap UV generator, as we deal with CAD models that we seldom unwrap manually, and thus get unusable results when we try to bake anything.

    And in our scenes, we have very large meshes and very small, highly detailed meshes, so I'm guessing this is a scenario that no lightmapper can perform well in...
     
    Last edited: Jul 9, 2018
  11. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Lots of the screenshots I posted use Unity's auto unwrap, even some of the Sponza ones, because I was trying it with both custom and auto. All big sunset city screenshots are auto.

    Here are some new screenshots with publicly available scenes, all using built-in UV generator. First scene is by LMHPoly. and the other is from the Blacksmith demo:

    photo_2018-07-06_13-04-40.jpg

    image.jpg
     
    CoastKid, TerraUnity, Mark_01 and 5 others like this.
  12. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    That denoiser makes an incredible job
     
  13. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    214
    Very interested. Im on a 1080ti and baking is cisting so much time so this could be a godsend. How much ?
     
    guycalledfrank likes this.
  14. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    If you mean the price, I think to start with something around $30 for the initial version and then gradually make it slightly more expensive, as it matures and gets more features.
     
    Mark_01, pcg and Vagabond_ like this.
  15. Osher

    Osher

    Joined:
    Feb 6, 2014
    Posts:
    11
    The lightmap is very clean so was wondering if you remember the rendertime and texel size on the blacksmith scene?
     
    guycalledfrank likes this.
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Took 20 minutes (1243.642 seconds in the log), but the resolution is CRAZY there. You probably won't bake with such resolution in a real game, because it's 7x4096x4096 lightmaps. These are baked shadows:

    photo_2018-07-06_21-40-59.jpg

    (If you're wondering about weird color spots, these are regular texture compression artifacts. Compression can be disabled on the assets as usual).
     
    CoastKid likes this.
  17. Osher

    Osher

    Joined:
    Feb 6, 2014
    Posts:
    11
    No wonder it is clean with so high resolution and I don't think 20min is slow at all considering such a texel resolution. Since we mostly do archviz it is nice to see what the lightmapper is capable to produce.
     
    guycalledfrank likes this.
  18. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Unity 2018 supports 8k maps and also some short of dynamic mip mapping, may be in future could you take profit of this.
     
  19. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Here is a seams comparison on a 128x128 lightmap. Same UVs, same scale in lightmap.
    Left: Bakery, middle: Progressive, right: Enlighten.

    photo_2018-07-09_14-30-47.jpg

    Note: the Stitch Seams checkbox on mesh renderer doesn't really change it.
     
    Last edited: Jul 9, 2018
    CoastKid, Mark_01 and Vagabond_ like this.
  20. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    925
    Really nice : )
     
  21. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Anyone experienced this when publishing assets?

    upload_2018-7-11_0-53-41.png

    I started creating the package description a few days ago (at publisher.assetstore.unity3d.com), and now I just can't load it. This circle can spin for an hour. Tried proxies and logging out/in again.
    And I can't create a new package.
     
  22. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,324
    Asset store publisher site has some problems today.
     
    Mark_01, brisingre and guycalledfrank like this.
  23. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    272
    Asset store publisher site has some problems.
     
    guycalledfrank likes this.
  24. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    And now... now we wait

    upload_2018-7-12_12-18-57.png
     
    TerraUnity, N00MKRAD, Mark_01 and 8 others like this.
  25. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    May be you could post some extra screens :DDDDDDDDD

    I'm busy now with other stuff but I've been waiting for something like this for ages.

    When you get the lightmap/realtime lighting blending to work I'll jump in (lods also needed for final build).

    Yo'll make my transition from Beast a breeze. Its amazing how a dude can beat in delivery time a company like Otoy or Unity implementing their radeonray solution. Congrats.
     
  26. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    83
    Waiting for the release the whole day is kinda boring.... :rolleyes:
     
  27. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    451
    I agree :D This is one of the times, it will seem time takes forever ... If they take a whole month ..
    we have a long wait ... 3 weeks still :(

    Hopefully it will be soon ..
     
  28. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    It's still pending review on the Asset Store :(
    Meanwhile, I'm working on some new features, so hopefully will post some new interesting screenshots soon.
     
  29. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,259
    Do you have plans to work on a mac version?
     
  30. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    That would be hard because:
    - I don't have a Mac (and they are pretty expensive).
    - Nvidia Optix support for Mac seems problematic.
    - Porting a lot of WinAPI and DX11 calls from all libraries to Mac/OpenGL (Metal?) would take quite some time.

    EDIT: I wonder if CUDA will work properly under VM running OSX... if so, then it might be doable.
    EDIT 2: seems like it won't work.
     
    Last edited: Jul 21, 2018
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    So I've just added support for vertex-baked lightmaps!

    Pros:
    - No UVs needed. Suitable for complex geometry that is impossible to unwrap well.
    - No space wasted - padding and empty spaces in the lightmap are not a problem.

    Cons:
    - Obviously vertex interpolation is less subtle than texel interpolation.
    - Normal texture compression techniques do not apply.
    - Modified shader needed.

    Some screenshots - the tree is 1.5 millions tris (good luck trying to bake it with built-in stuff or even unwrapping), and the last is just a comparison between texture and vertex lightmaps (only spheres change - floor uses texture lightmap on both).

    Untitled-4.jpg tree22.jpg vert11.jpg
     
    CoastKid, RomBinDaHouse, pcg and 7 others like this.
  32. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,017
    Can you mix and match? I've always wanted to use vertex-baked lms for small meshes, while the rest used normal texture based lightmaps.

    Edit: Now that I re-read your post I guess the answer is yes, since you say the floor is texture lightmapped on both :)

    I've been wanting this feature for years.
     
    Last edited: Jul 22, 2018
  33. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,607
    HOLY, just became a must buy!
     
    guycalledfrank, AcidArrow and Mark_01 like this.
  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Yeah, you can. You just add a component on the parent object, mark it as vertex-baked and then children (and the object itself) will be lightmapped this way.

    This component also allows you to sort certain objects into their own lightmaps and set their resolution manually. Without it, Bakery attempts to sort and pack everything automatically, similar to how built-in lightmappers do.
     

    Attached Files:

    Last edited: Jul 22, 2018
    pcg likes this.
  35. N00MKRAD

    N00MKRAD

    Joined:
    Dec 31, 2013
    Posts:
    204
    Is there ANY chance of getting runtime baking at some point?
     
  36. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Vertex sounds cool for "unwrapable" stuff. Image compresion destroyed the balls example image.
     
  37. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    226
    Hi,
    I've a bunch of questions, hope you can find sometime to answer.

    -Are there any test that use transparent and/or displacement shaders?
    -Do you create a new mesh file after you bake to vertex? also same goes for fixed UV seams and Atlas packing I guess.
    -What are the options when it comes to the generated lightmap file (file type, resolution, compression ?) Can we specify EXR layers for baked information (shadow, direct, indirect...)
    -How do I specify which object goes into which lightmap? Does "Lightmap Group Selector" component is responsible for that? Is it easy to just select a bunch objects from scene view and specify where and how they'll be baked?or is it a manual process?
    -How does it look in mixed lighting situations? Can you please show some video examples with mixed lighting?
    -I'm guessing it would be possible to switch between different lightmaps of the same scene at runtime? morning-midday-night...

    Good luck with the release :)
     
    guycalledfrank likes this.
  38. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,259

    You could try hackintosh :)
    From what I read Optix 5.0 seems fine on the Mac just the 5.1 need an update with Mac binaries.

    Still would be awesome in the near future if Titan V's are working in the Mac ( even via eGPU could be an option ) and we can light map fast.

    Thanks for investigating, Hope unity will also come out soon with the gpu lightmaping, will look at that as a Mac solution for now
     
    guycalledfrank likes this.
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Unlikely - architecture is not suited for this task.

    For now only the Standard shader is supported. Other shaders can work too, if they use identical names for parameters (e.g. _MainTex). Transparency works (although no partial transparency at this point). Displacement is not supported - meshes are used directly.
    Supporting custom shaders is hard, because I don't know any sane way to get separate color/opacity/emission from them, let alone vertex shader displacement. Unity itself has a sophisticated surface shader parser, and that helps them to get more information, comparing to what I can get. It's still on my TODO list though, and I'll take a look, but it's not an easy task.

    Yes, just with colors. I then attach it to MeshRenderers using additionalVertexStreams. So the original mesh is unaffected, and multiple differently lit instances work.

    Seam fixing is a texture postprocess, so it doesn't affect the mesh. Atlas packing only affects meshRenderer.lightmapScaleOffset. There is however also a UV padding fix that modifies automatically unwrapped UVs - this one is done via asset postprocessor.

    All lightmaps are saved to .HDR files and become normal assets. You can change their max resolution, compression and other stuff like with built-in lightmap files. Layers is something I'm really looking to implement, but it's not there yet.
    By default all lightmaps get generic names and automatically calculated resolution (based on scene-wide "texels per unit"), but you can override that and manually specify which objects should be rendered to which lightmaps and in what resolution.

    The Group Selector component is optional - you only use it when you want to fine-tune something. By default automatic lightmap sorting/packing handles most scenes well, not worse than Unity's.

    Shadowmask mode is something I'm going to impelement soon. For now you can only specify which lights are fully baked (direct + indirect) and which ones are indirect-only (when the direct part is real-time). I attached a comparison from the manual.

    It's possible using normal scripting functions and with the help of the Group Selector component, yeah. You can bake lightmaps with specific names for every time of day, then load them and insert into Unity's lightmap array at runtime.
     

    Attached Files:

    • mix.jpg
      mix.jpg
      File size:
      335.5 KB
      Views:
      557
    Last edited: Jul 23, 2018
    Mark_01 and gurayg like this.
  40. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,017
    Add meta pass support so we can write our own meta passes to feed stuff to your lightmapper? Meta pass is fairly straightforward.
     
  41. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Can you elaborate? How do you imagine (ideally) the way you would define a meta pass?
     
  42. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,017
    The meta pass is how Unity sends data to the lightmappers.

    Read this:
    https://docs.unity3d.com/Manual/MetaPass.html

    It is auto-generated for the Standard shaders, but I'm writing my own for my own custom shaders. I usually just recreate parts of the main shader and add the ability to adjust saturation (in case I want more color bleed or something like that).

    Presumably, you should be able to read the meta pass and use that for the representation of the material for baking.

    (or maybe not? Maybe there is something missing that stops you from doing that? But if there is a way to do it, I think it's the way to go, since it would be most compatible with anything else that Unity does for lightmapping).
     
    guycalledfrank likes this.
  43. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    102
    Hello! Looks great!
    If you plan on adding support for the meta pass, please add advanced features such as colored shadow and custom opacity for shadows. For example, it will be very useful for color shadows from grass, leaves, stained glass and other semi-transparent objects. Custom opacity helpful for alphatest decals driven by vertex color and other stuff like this.



    gif3.gif gif.gif
     
    Gametyme, red2blue and guycalledfrank like this.
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    Oh, somehow I didn't know that! Maybe I'll be even able to use existing meta pass, but if not, custom Bakery pass can be defined.

    For opacity, meta pass is less applicable though.

    Similar to Unity I render surface attributes to what I call UV GBuffer, where instead of separate albedo textures, you have one combined in lightmap space. However, that means textures' texel size gets downsampled to lightmap texel size. If for color bounces it's not a problem (low frequency effect), it's not so good for opacity. E.g. imagine thin chainlink fence - drawing it in a meta pass using lightmap UVs would shrink it down so much, it would lose its shape.
    Therefore I export alpha maps without any changes in size, so very sharp and accurate shadows can be traced.

    This is not supported yet, but eventually will be.
     
    Dawie3565 and Mark_01 like this.
  45. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    102
    Yes, you right. I foggot that meta is in Lightmap UV space.
    So there is no any other way to set custom alpha?
    Because of this limitation, we tried to use a Vray. But this pipeline requires a lot of extra working time for export, setting up materials, etc.
     
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,126
    I see. There is no easy way - I can add support for meta opacity, but precision/shadow detail will suffer.
     
    Mark_01 likes this.
  47. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    102
    It would be mach better than nothing!

    I have a couple more questions.
    1. Does your baking tool support Pushoff setting as Unity? It very useful in some cases.
    upload_2018-7-30_11-41-58.png

    2. What about light transport?
    You can see the PLM problem in this post. Indirect light too dark.
    https://forum.unity.com/threads/progressive-lightmapper.454362/page-13#post-3479509
    https://forum.unity.com/threads/not-enough-light-bounce.536046/

    3.Is it possible to add normal map support for simple indirect lightmap? As it was done by the Beast in unity 4.
    I understand that the resolution of the details will be low. But this is useful for giving extra volume when there you can't use directed lightmaps and normal maps (Still too heavy for mobile).

    https://forum.unity.com/threads/bake-normal-map-with-enlighten.435238/
     
    guycalledfrank likes this.
  48. oLDo

    oLDo

    Joined:
    Mar 14, 2017
    Posts:
    53
    Hi. Can I test it somehow? I didn't find any download options.
     
  49. MAXFORCE

    MAXFORCE

    Joined:
    Mar 4, 2014
    Posts:
    30
    When will be released update in assetstore?
     
  50. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    716
    Can support with asset bundle?