Search Unity

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

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

  1. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    After the bake is done, it should print the time it took to render in console. Or what do you mean?
     
  3. theorchestrator

    theorchestrator

    Joined:
    Aug 9, 2013
    Posts:
    8
    Having a strange issue when setting bakery to Shadowmask mode. No light gets applied except for the dynamic objects but they dont throw shadows. Also reflection probes are not getting baked either. Lights are set to shadowmask. Everything seems to work just fine when set to Full Lighting. Help appreciated :)

    Edit: Batching also doesn't seem to work anymore. More than double and tris count 4x
     

    Attached Files:

    Last edited: Aug 28, 2018
  4. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Can you make a screenshot of some light you have, with both Bakery and Unity components visible? Also, what Unity version are you using?
     
  5. theorchestrator

    theorchestrator

    Joined:
    Aug 9, 2013
    Posts:
    8
    Using 2018.2.5f1 (newest availible)
     

    Attached Files:

    guycalledfrank likes this.
  6. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    That's weird. I can suspect you have a lot of lights set to shadowmask. Does it work if you:
    - Disable Shadowmask on all lights except one
    - Instead enable Bake To Indirect on them
    Will the one shadowmasked light work correctly?
     
    theorchestrator likes this.
  7. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Sorry - I don't see that. The small progress window dissapear and in Bakery tab there's no such information.
     
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Well it should be here:
    upload_2018-8-28_20-16-17.png
     
  9. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    where should I turn it on because I do not have it?
    Unity 2018.2.5f1
     
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    It's always on. Are you sure the lightmap is baked? Is there any text at all in the console?
    Note that this text is only printed right after the bake is finished. If you close Unity and open it again, it will be gone.
     
  11. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    After baking - there's no info in console.
     
  12. theorchestrator

    theorchestrator

    Joined:
    Aug 9, 2013
    Posts:
    8
    Yes it works up to two lights set to shadowmask. Third one breaks everything. I also cannot use baked reflection probes. It gets reset when entering playmode. Throwing this error:
    Unbenannt.PNG
     
  13. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    It should definitely work with up to 4 overlapping lights (and more, if they don't overlap).
    example_shadowmask uses 3 lights.
    Can you try reproducing this scene on simpler geometry and send it to me?
     
  14. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    I'm also not seeing shadowmasks. I went back to 2017.3 to check the difference between HDRP and standard with this, but I can't get it to work. It creates the lightmaps, but they dont actually get shown. When I use enlighten it works fine.

    I did enable shadowmasks on bakery. I'm not spending a lot of time on it at the moment, so it could be on my end, but just flagging it since someone else mentioned it.
     
  15. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Do they work in the example scene (example_shadowmask?)
     
  16. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Will check as soon as I'm able to. I should just re-run the Bakery render when opening that scene, right?
     
  17. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    This scene should work out of the box without re-rendering, but you can also try to re-render and see if there is any difference.
     
  18. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    457
    On HD SPR Shadowmask seems to don't work. (Shadowmask Distance works instead)
    I am missing something? Or it's a bug ? Shadowmask_HD SRP.JPG
    Shadowmask_Standard.JPG
     
    Last edited: Aug 28, 2018
  19. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Does it happen with Enlighten/Progressive shadowmasks too?
     
  20. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    457
    Sorry again my mistake. I have to turn ON "Non Lightmapped Only" on Unity lights.
     
    guycalledfrank likes this.
  21. ngfilms

    ngfilms

    Joined:
    Nov 18, 2015
    Posts:
    30
    apologies guyCF , my issue regards to ram is depreciated : i hadn't realized that you've updated bakery , this version seems to have dealt with the ram issue as it now stays well below below my ram limit ( of 16gigs ) so on that note : i was able to render the scene and do a comparison with approx the same texel /res . .. the winner is .. not .. UNITY progressive renderer = 9 hours & Bakery = 2 hours .
     
    NoobDoAAA and guycalledfrank like this.
  22. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Oh, maybe you have this button unpressed? It should be on.

    upload_2018-8-29_10-0-11.png
     
  23. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Yes!, Now I see that - thanks!
     
    guycalledfrank likes this.
  24. Xeverian

    Xeverian

    Joined:
    Sep 23, 2016
    Posts:
    12
    So I've tried testing new 1.2 version in Unity 5.6.3p1 and found some weird bug. I've removed the Bakery folders from the project and imported a new version. I've tried baking shadowmask in a simple scene with terrain and couple of rocks on it, all marked as static, with single directional light (added the bakery light component there as well) and sky light. Unity no longer crashes when Bakery asks you if you want to save the scene and it starts baking correctly as it seems but in 3 out of 4 tries I've got this after the baking (picture 1). The scene just becomes empty with empty Bakery window on it. When I try closing Unity it asks if I want to save the scene (that simple scene with terrain, not the new empty one). I'm clicking "save" and next time I load Unity it shows me my scene with baked lighting and bakery window (picture 2). The lighing seems to be correct but I'm not quite sure (I've set the light intensity to 5 here to make the effect of normal maps more visible). I've noticed that when it worked one time I didn't switch to another window (browser etc) while baking. However when I've tried it again I've got the same bug.

    1)
    2)
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Huh interesting. So it happens when it starts the bake (before adjusting samples, etc) or when it's finished?
    Looks like a some kind of bug related to scene load/unload. You can 100% avoid it by going to Advanced settings and disabling the "Unload scenes before render" checkbox. The reason Bakery unloads scenes is to free up video memory for lightmapping, but it's only really needed for big scenes.
    But I should fix it anyway. Can you show me what's in the console when it happens?

    Looks good to me - maybe try applying white materials to see the lighting clearly.
     
  26. Xeverian

    Xeverian

    Joined:
    Sep 23, 2016
    Posts:
    12
    When it's finished

    Sure, I'll test it a bit later and will post the log here. Just to make sure I understand it correctly: with shadowmask baking only indirect light is baked and direct light is realtime? And the second question is: other than leaving the unity light with bakery light attached and shadowmask enabled active after baking, do I need to modify any settings in Unity's lighing tab?
     
    guycalledfrank likes this.
  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    There are some illustrations in the docs: https://docs.google.com/document/d/19ZDUAVJA69YHLMMCzc3FOneTM5IfEGeiLd7P_qYfJ9c/edit#

    Also I postead an explanation pic here: https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-2-released.536008/page-9#post-3605442

    Both indirect and static shadows are baked. What's not baked is dynamic objects' shadows and surface lighting response (bump/spec/smoothness/etc).

    No, you don't have to. Bakery should be able to setup everything by itself, unless you are on 5.6 (and now I see you are), in which case to switch between regular Shadowmask and Distance Shadowmask, you'll need to do it here:
    upload_2018-8-30_10-36-31.png

    The difference is that in "distance" mode all nearby shadows are completely real-time (so only indirect is baked indeed), but in the distance baked shadows are used.
    In the non-distance mode, baked shadows are also used close to camera.
     
  28. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Posts:
    22
    This looks awesome, especially like the idea of a "render selected" button.

    What I really want though is the ability to export a lightmap to UV coordinates to use as a detail texture so I can have a lot of prefabs with pre-baked lights for randomized generation. Is this possible?
     
    DGordon likes this.
  29. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Woah. That would be awesome. I wonder if you could even export multiple versions of different light strengths, or door positions, or whatever, and blend between them.

    I like where you're going :).
     
    gterveen likes this.
  30. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Thanks! Not sure I correctly understood the "detail texture" idea, but there IS a way to have lightmapped prefabs sharing the same texture. It's currently undocumented, and I'm not sure how to expose this functionality, but I helped one dev to make it work with his custom scripts.
    When you render any scene with Bakery, it creates an invisible object with some data like the lightmap array and which mesh uses which. When Awake() is called on this object, it immediately applies lightmaps to the scene.
    Because of this approach, you can naturally put these objects into prefabs and get lightmapped prefabs:

    upload_2018-8-30_18-28-28.png
     
    DGordon and gterveen like this.
  31. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Posts:
    22
    If you manage to expose it in a manner that it looks like supported feature that I can use I will buy right away!

    I am waiting for Unity to make light baked prefabs simple and usable ...

    I would really love to be able to use a UV1 standard texture with light baked into UV2 as detail (I might be using wrong terminology here ... not a pro). To be sure I can reuse it with all Unity versions I would want to be able to export that texture (one texture per mesh would be fine - I can mesh bake every prefab and atlas the UV1 textures).

    This would allow me to create different color version by switchting UV1 texture ... and different light versions by switching UV2 texture. One could even do stuff like making a light go on by blending 2 UV2 textures from no-light to light.

    Lots of cool stuff that one can do that way ... if only I had a tool inside Unity that lets me bake light into a detail texture. :)
     
    NoobDoAAA and guycalledfrank like this.
  32. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Would be OK for you if you'd need to create and bake the prefab in a separate scene and then click something like "create baked prefab from scene"?
     
  33. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I downloaded latest version
    I tried first full ligthing because I thought shadowmask mode was read from lighting panel. I saw it was not.
    So I rebake with shadowmask mode set in bakery panel but only indirect seems to be baked
    upload_2018-8-30_20-20-44.png

    upload_2018-8-30_20-21-40.png

    Unity light component was dissabled but it is not needed right?

    Also I notice directional light is ligthing the whole scene.

    I've not cleared all ligthmap data and started a rebake just in case.
     
  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    You almost did it right. Now also enable that "shadowmask" checkbox on the Bakery Direct Light and rebake :)

    For the shadowmask mode it should be enabled.
     
  35. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Lol, how did I miss that! :D
    Shame that I had not seen befor relaunching bake, so here we go... baking again... :D
     
  36. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    When baking scen ewith shadowmask took longer, but it finished computing, yet, it did not come back and lost the lightmap assignments.:\ I could move the Bakery floating window, I closed it but unity was non reponsive I could not touch any menu but etc. Initially iwth no shadowmask it was like 350MB and measruing hte size of all LM in the folder after thhe bake it hickup it was like 2gb or so so I guess it was ismply too much.
     
    Last edited: Aug 30, 2018
  37. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    What do you mean? When did it stop? What was the last thing displayed on the progress bar?
     
  38. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    OK simply backed with less texel size for giving it a go, How did the normal maps became visible
    at the absolute end, progress bar was finish, you know how it unloads the scene? it failed to load back and apply the LM.
     
  39. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    OK simply backed with less texel size for giving it a go, How did the normal maps became visible on lightmaped surfaces! didn´t whe need directional LM?!
    I'm noticing that the detail mask texture is not being applied.
    edit: the issue with the detail was a weird thing with that specific material
     
    Last edited: Aug 30, 2018
  40. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    tweaking the shadow streng you can get completelly rid of the transition effeect:
    upload_2018-8-30_23-8-6.png
     
  41. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    It works because your directional light becomes real-time, except its static shadows (the slowest bit) are baked, so it's also cheap. Directional LMs will help with bump in shadowed/completely baked areas.

    Are you sure? Sounds like what keltrivera described above. However I never encountered that. Does it help to simply click on the viewport or something? Is it completely frozen?

    There shouldn't be any, strength=1 should work well.
     
  42. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I had strength lowe than 1 :D;

    I'll check his issue. Editor was semi alive. Your window was live and could close it but editor was freezed, hwen clicking on it it made the bell sound. Had to terminate unity.

    edit: I didnt know that you could modify ligth strenght and that the skylight would remain, this is very very cool.
     
    guycalledfrank likes this.
  43. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Posts:
    22
    I don't think that would result in a manageable workflow. I would want 50 objects in a scene, set the directional light for all of them in one go and then say "go and bake these 50 objects into 50 prefabs with a light texture on each" ... then I would copy the processed textures, turn the light 90° and bake them again and repeat that until I have the light/shadow from all 4 sides so I can rotate them in 90° steps when I put together the random level pieces.

    and then I would use another 50 pieces for dungeons that don't need the directional lights, but instead get point lights baked in.

    A typical solution that would allow me to build levels with these pieces would be qmaze.

    And to add a little tricky bit ... I have baked AO, soft edges and fake light before on these pieces ... and it is helpful to have fake geometry at the borders to not create visible borders on the geometry. So yeah ... it is a bit of a bigger task ... but one that I think could enable a lot of one man indies to create quite beautiful worlds :)
     
    NoobDoAAA likes this.
  44. NoobDoAAA

    NoobDoAAA

    Joined:
    May 7, 2018
    Posts:
    11
    It's not clear for me - can it bake single objects on scene only - not entire scene?
    For example if I have a huge scene and want to bake only some buildings on it.
    Can it be done or not?
     
  45. josephtamhk

    josephtamhk

    Joined:
    Jul 24, 2017
    Posts:
    4
    Is it possible to bake the static objects in full lighting mode and illuminate dynamic objects using mixed light while casting dynamic shadow on the static objects?
     
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    OK. Maybe a component on the parent object that would say "this is a prefab and I want all prefabs of this kind to share the lightmap"?

    It's a bit tricky at the moment. Render Selected bakes the whole "Lightmap Group" to which currently selected objects belong. Lightmap Groups can be either defined by hand (using the Lightmap Group Selector component), or they are created automatically.
    Lightmap Group = list of objects and 1 lightmap.
    So when you're not using the component and get multiple lightmaps, that means the scene was auto-split into multiple Lightmap Groups.
    Another limitation is GI. When the light is bounced from one Lightmap Group to another, it will read previously baked lighting from another group. So if you render selected, but everything else is unbaked, then unbaked objects won't reflect light to the one you render.
    It's still work in progress and I'm planning to make this feature more useful. For now, if you have some objects that you want to rebake often without re-rendering the whole scene, I suggest adding the Lightmap Group Selector component on them (read the docs), bake the whole scene at least once with crappy settings and then use Render Selected on the objects that have the component.
    You can also take a look at Sponza example, it has bushes using this component. Makes them easily re-bakeable without re-rendering the whole scene.

    Yes, that's what Shadowmask mode is for.
     
    NoobDoAAA likes this.
  47. saytomorrow

    saytomorrow

    Joined:
    Aug 30, 2018
    Posts:
    1
    @guycalledfrank Does bakery 1.2 work with Unity 2018.2 Scriptable Render Pipeline, especially the Lightweight Render Pipeline?
     
  48. josephtamhk

    josephtamhk

    Joined:
    Jul 24, 2017
    Posts:
    4
    As far as I know, in shadownmask mode only indirect color is baked into the lightmap.
    What I would want is direct color also baked.
    In other words, I would want a mixed lighting with substactive lighting mode just like the built-in lightmap solution.
     
  49. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Yes it should!

    No, in shadowmask mode there are 2 textures baked: one with indirect and one with shadows. Separating them allows to combine dynamic/static shadows. Read this carefully: https://docs.unity3d.com/Manual/LightMode-Mixed-Shadowmask.html

    I'm not altering Unity's lighting modes, only providing a different way to bake the maps.
     
    NoobDoAAA likes this.
  50. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Thanks for your detailed reply earlier @guycalledfrank still doing lots of testing and am enjoying the quality of the results.. Am taking notes of more concerns as they appears.

    This one happens when importing to a project that isn't using terrain and had to manually edit out references and functions related to terrain.

    Assets/Bakery/ftLightmapsStorage.cs(110,17): error CS1070: The type `UnityEngine.Terrain' has been forwarded to an assembly that is not referenced. Enable the built in package 'Terrain' in the Package Manager window to fix this error.