Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

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

  1. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Does it help to manually set it to force OFF?
    What error message do you see exactly (error code matters)?
     
  2. DevelopedReality

    DevelopedReality

    Joined:
    Jul 14, 2015
    Posts:
    25
    It doesn't crash if it's forced off (or on auto)--only when I try to force it on. When that crashes it, I get this error in the console:

    BakeryCrash_GIVRAM.PNG

    When it crashes during the alpha buffer export the entire unity editor crashes right here: BakeryCrash.PNG
    Not sure if there's any relationship between the two.

    Thanks for the help!
     
    guycalledfrank likes this.
  3. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    OK, the alpha buffer crash is interesting. Can you go over all your cutout/transparent materials and see if there is anything unusual? Can you try creating a separate simple scene with all your transparent materials together? Will it crash?
     
  4. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    52
    Just to follow up on my issue, I created a new scene a copy/paste everything from the old scene to the new one, I kept the same configuration for my bake and no error at all, so it looks like something was corrupted on my previous scene.
     
    guycalledfrank likes this.
  5. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Ok yeh - that was our workaround for now, thanks!

    By the way, just to put this in context, it's only one or two objects that display the errors in the screenshots I posted (albeit 'randomly' ) . Otherwise Bakery has been quite beneficial to our pipeline, being able to bake entire Scenes in <30minutes instead of days - or simply failing to build with Progressive - puts a different perspective on being able to iterate on scene lighting! Thanks for the efforts!
     
    guycalledfrank likes this.
  6. bha_unity

    bha_unity

    Joined:
    Jun 18, 2018
    Posts:
    2
    Hi guycalledfrank first things first - awesome tool. Really handy when you have a limited amount of time!

    Nevertheless I am facing serveral issues here on Unity 2018.2.8f1 with a GTX 1080Ti:

    1. It seems the Render Seleceted Group feature doesn't work. After the bake Bakery puts random Lightmaps on the other things I didn't want to bake (Object is marked as "Static" and has a new Light Group with resolution override of 2048).
    2. I often get the Error "ftrace = problem 1001" or something like that. (seems to have to do with the Render selected Group feature/ sometimes appears on normal Render All process)
    3. Sometimes when I hit "Render" it gets stuck at 50% trying to prepare lightmaps baking.

    Btw on Windows there seems to be issues not using Unity as Admin (or UAC in general). I need to start Unity as admin to change the Tweak section. But when I use Unity as Admin I can't drag&drop things from the Explorer or change Prefab values.
     
    guycalledfrank likes this.
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    If you are not using Lightmap Group components, then objects are grouped automatically into multiple lightmaps. That means if you change objects or their resolution, the whole scene will end up regrouped differently, and that's why you get the results you get. I'm not sure how to properly avoid it yet... but for now I recommend only using this button on objects that have manual Lightmap Group assigned.

    Can't happen. Can you find the exact sequence of steps leading to it, so I can reproduce this behaviour?

    Any console errors?

    For some reason I'm able to use it in non-admin mode (I have UAC on, and Unity never asks for permissions), but I heard multiple reports of what you describe. I wonder if it's because I have Unity installed in a non-important folder, and you perhaps have it in Program Files?
     
  8. DevelopedReality

    DevelopedReality

    Joined:
    Jul 14, 2015
    Posts:
    25
    Tried this and couldn't find anything unusual w/ the few cutout/transparent materials I'm using. Tried baking with all of them alone and had no issue. Then I tried turning all the models in the scene off and then back on one-at-a time, and was able to bake the scene with everything except one model prefab (the largest model). BUT, I can get that model to bake just fine in an empty scene and I can also get it to bake fine in the same scene with other models turned off so I'm not sure that model is even the issue (very simple materials w/ no transparency). Could it be a memory issue? This is a pretty big scene.
     
  9. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    52
    Is the lightmap switch support still on your roadmap? If so, do you have a version ETA?

    If not, I'm looking to transition smoothly between two big lightmaps what would be your approach?
    Thanks a lot
     
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Possibly. Can you try setting Texels Per Unit to 0.1 and see if it helps?

    Yes.

    Not sure yet. Currently fixing bugs and going to properly dive into probes.

    Hmmm. In case of same-scene-different-lighting scenario, I would:
    - Bake it with different lights into different folders.
    - Make a script with additional lightmap array and plug the second set of lightmaps into it.
    - First set of lightmaps will be loaded as usual.
    - Then this script would go over baked mesh renderers, look at their lightmapIndex and use MaterialPropertyBlock to assign 2nd lightmap. Something like this:
    Code (CSharp):
    1. var storage = GameObject.Find("!ftraceLightmaps").GetComponent<ftLightmapsStorage>(); // get Bakery scene data
    2. for(int i=0; i<storage.bakedRenderers.Count; i++) { // loop over baked renderers
    3.             var renderer = storage.bakedRenderers[i];
    4.             int lightmapID = renderer.lightmapIndex.
    5.             var prop = new MaterialPropertyBlock();
    6.             renderer.GetPropertyBlock(prop);
    7.  
    8.             // Assign your additional lightmap
    9.             // "secondLightmap" is the shader variable name
    10.             // secondLightmapArray is your array of additional lightmaps
    11.             prop.SetTexture("secondLightmap", secondLightmapArray[lightmapID]);
    12.  
    13.             renderer.SetPropertyBlock(prop);
    14. }
    - Now you also need to use a custom shader that would read the additional lightmap and perform interpolation.
     
    Balours likes this.
  11. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    I am using rnm directional mode for my room GI, but whenever I don't use the bakery shaders for specific props the models appear super bright and broken when rendered in deferred. Can you implement a double sided option to the bakery shaders to they work for my models or tell me how to make them not look so bright when rendered?
     

    Attached Files:

  12. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Is the model static or dynamic? Does it use lightmaps or not?

    I can make an option to simply render both sides, however, the lighting is going to be the same on both sides, as only one side is unwrapped.

    Neither directional mode will work properly with doublesided shaders (even the classic Unity built-in one), as directional information is captured relative to surface normal (we know nothing about lighting coming from the back hemisphere). The best possible fallback is to use flat non-bumpmapped non-shiny lighting on the back side.

    Also, as mentioned in the docs:

    In RNM and SH modes, standard color lightmaps are not created. You need to either have Bakery shader on all materials in the scene, or use Lightmap Groups to separate RNM/SH objects from the rest.


    That means there is simply no classic flat-color lightmap generated in RNM mode, that would be compatible with non-Bakery shaders. There are options though:

    a) As the docs suggest, you can use the Lightmap Group components/assets to mark certain objects as RNM (or non-RNM - if the majority of your objects are using Bakery shaders). Nothing prevents you from using some objects with RNM lightmaps + Bakery shader AND some objects with non-directional lightmaps + other shaders in the same scene.

    b) Patch your own shader to be able to use RNM. You can take a look at Bakery.cginc and copy-paste some parts of it. If shader writing is not your thing, you can send the shader to me, and I'll try to help you. Recently helped one person to integrate directional specular into Alloy shaders, it wasn't hard :)
     
    Last edited: Nov 4, 2018
  13. Markus0638

    Markus0638

    Joined:
    Sep 29, 2017
    Posts:
    3
    Hi Frank, I just started using your asset but I'm really impressed how well it works and how fast it is!

    However I have one issue. I have a very big scene so I render parts seperately with lightmap groups and disable gameobjects I dont need including objects with lightmap groups attached. When I reactivate them after I rendered a different object they seem to have lost their lightmap, although its still in the project folder. Through try and error I found a workaround. After I'm done rendering I render a dummy object with a lighmap group while all other objects are activated. After doing so the lightmaps are properly displayed again. Any thoughts on that?

    Thanks a lot!
     
    guycalledfrank likes this.
  14. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    That helps a lot, I just need double sided to fit my project needs, but I can do groups until that gets implemented.
     
  15. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Objects don't store which lightmaps they use. Instead, this data is stored globally in the scene. So when you rebake the scene with some objects deactivated, the new scene storage doesn't include them.
    The lightmap files, however, are never deleted... because I'm just paranoid about deleting any files, especially if you spent minutes generating them.
    A simple solution would be to use multiple scenes instead, bake each separately and then put them all together. This way every scene would have its own data and it wouldn't overwrite other scenes. This will require loading the scenes at runtime via LoadScene() though.
    Do you use Render Selected when baking the dummy object? This can work indeed, as it skips rendering irrelevant groups, BUT it finds the right maps for them and re-applies.
    Instead of using the dummy object, you can also go to Experimental mode, unckeck ALL checkboxes in "Lightmapping tasks" and press Render. It won't render anything, but it will reimport and reassign all maps.
     
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Alright, here you go. This package updates the Bakery shader, and you should see a "Double-sided" checkbox now.

    BTW, just curious: why did you decide to go with RNM instead of SH?
     

    Attached Files:

    Last edited: Nov 5, 2018
  17. Markus0638

    Markus0638

    Joined:
    Sep 29, 2017
    Posts:
    3
    Yes, I use render selected when doing so. I tried your idea. First it got stuck on AO with memory allocation failure. After setting intensity to 0 I get "halffloat2hdr error: 23" when encoding one of the lightmap groups.
     
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    OK well perhaps it's broken then (that's why it's buried deep into Experimental settings). Either continue doing your dummy render trick or split separately baked groups into separate scenes. You can also use the prefab trick to create the final scene instead of LoadScene.
     
  19. Markus0638

    Markus0638

    Joined:
    Sep 29, 2017
    Posts:
    3
    Any chance for a button solely for reapplying the maps or maybe a command i could execute? My issue is not the render time of the dummy cube, but the time it takes to export all objects of the scene at once.
     
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    I don't have such button at the moment, but can add it the future.
     
  21. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,199
    Maybe this is the wrong thread but I wanted to compare Bakery against VRayNext or Redshift for 3dsmax.
    But both renderer don´t support denoise on RenderToTexture.
    Any idea why and if this might get fixed?
     
  22. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    ...are you asking about Vray's RTT denoise? I have no idea :)
    I don't think they are serious about being used for lightmapping.
     
  23. luoshuangfw

    luoshuangfw

    Joined:
    Sep 1, 2018
    Posts:
    1
    Yep I've tried the most recent VRay for Unreal once and the baking is absolutely horrible...
    Btw nice to meet you again - from Luoshuang
     
    guycalledfrank likes this.
  24. ViewportAU

    ViewportAU

    Joined:
    Mar 26, 2014
    Posts:
    25
    Hello Frank. Do you have an estimate release date for v1.41 or above? Including uvw mapping hotfix, optix update and lightmap checkboard visualization?.
     
  25. Ruuubick

    Ruuubick

    Joined:
    Apr 20, 2014
    Posts:
    15
    Hi Mr. F !

    This may be a stupid or redundant one, but i was wondering if there were plans for adding an option to compress the lightmaps in the future ? (this may already be done automatically, i'm not knowledgeable on the topic) Since the lightmaps for my project make up for half the weight of the scene and i'm not able to use crunch compression, another way to reduce the lightmap size would be great ! Thanks !
     
  26. HenriSweco

    HenriSweco

    Joined:
    Aug 8, 2016
    Posts:
    28
    What would cause the entire scene to be baked into a few overlapping lightmaps? I don't have any different settings, and it worked when I exported the scene as a package and moved it to an different Unity project which had baked normally.
    Capture.JPG
     
  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Hi hi!

    Probably this week. Perhaps I'll fix a couple more bugs.

    The lightmap assets are regular textures and use the same compression Unity applies to its own lightmaps (BC6H on desktop/consoles, DXT5 on lower end, ETC/ASTC/PVRTC on mobile, etc...)

    Why is that?

    Using custom UVs? This might be a 1.4 bug I recently fixed (not present in 1.3). A package with the fix was posted in the thread.
     
  28. DevelopedReality

    DevelopedReality

    Joined:
    Jul 14, 2015
    Posts:
    25
     
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    There is definitely something very wrong with the scene you have, and I'm out of ideas. If you can send me the whole project, I'll debug, but so far I don't know any other reason/solution for the behaviour you experience (apart from what I previously suggested). Have you tried baking on a different PC?
     
  30. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,199
    I have a Group Selector on my Floor-Object and wanted to render it separately.
    Then I got an ftrace error and all the other lightmaps got unassigned.
    Complete scene is unbaked now.

    I tried your hack unchecking everything under "Lightmapping tasks" and render but no success, got "Error: 23" then.

    We definitively need a way to reassign all the lightmaps by one click.
     
    Markus0638 and guycalledfrank like this.
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Any details/screenshots/logs?
     
  32. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    301
    Quick question, which may be hidden somewhere in the docs or this forum thread - appreciate any help!
    Set up the whole scene to bake, does it fine.
    However, when all the lightmaps generated by bakery get comped together, the placements of those comped LMs do not go along with the uv2 inside of Unity?
    I'm sure im doing something wrong.. but what...
    Thanks for anybody that can shed some light into this.

    (p.s: I know the uv2 looks terrible. This is just a test for a large scale space )
     
  33. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_12-51-50.png When I am doing shadow mask lighting occasionally lights just stop doing shadow masks anymore and the light becomes completely non reactive unless i go into debug and turn off "is baked" and then rebake it. This happens at random and I cannot see a way to fix it other than to manually remake the light.
     
  34. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_12-59-41.png this is what it should normally be doing, but half the time it doesnt. All my shaders are bakery, with rnm and specular applied, I use the same settings on this room that I used on other rooms with shadow mask -- it normally works but when it breaks, it breaks for good, not even clearing all the data fixes it.
     
  35. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Do you use custom UV2 set (not generated by Unity) and get UV mapping all messed up after bake?
    If so, try the patch from this post: https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-4-released.536008/page-24#post-3801826

    What version of Unity are you on? There are some crazy workarounds on everything below 2017.4 due to a lack of proper shadowmask API.
     
  36. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    We are on Unity 2018.2.14, no HDRP or new render pipeline yet. I can show any of my project settings or GI settings, this happens randomly since I downloaded the asset a month ago, and it happens regardless of what scene it is baked in or if unity is refreshed. manually re creating the light from scratch with the same settings has fixed it before. Disabling "is baked" makes the unity light component responsive again. Lightmaps are generated by unity for my models
     
    Last edited: Nov 6, 2018
  37. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Are you on 1.3 or 1.4? There is a tooltip showing the version number if you hover the mouse over the blue "Bakery - GPU Lightmapper" text. There were many bugfixes in 1.4
     
  38. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    We are on 1.4
     
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Well, that's weird. I never heard of any similar reports before and I didn't experience it myself. Do you by any chance have lots and lots of potentially overlapping shadowmasked lights?
     
  40. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_13-40-59.png Several lights have GI, but show no shadowmask. While I was working they had shadow mask for a while, but after a few bakes many of them stopped and have been unable to bake shadowmasks since then. yes this room is heavily dependant on shadowmasked lights to reduce casters, they may overlap.
     
  41. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_13-49-53.png some lights in the same scene have it and are responsive to the light component. The light next to it also has shadowmask and overlaps with the other one.
     
  42. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_13-58-17.png here are two lights that are exactly the same, one with shadowmask working and one without
     
  43. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    upload_2018-11-6_14-6-25.png this seems to be why, I see that someone else has had this error before.
     
    Last edited: Nov 6, 2018
  44. zornor90

    zornor90

    Joined:
    Sep 16, 2015
    Posts:
    183
    Hey @guycalledfrank, out of curiosity, do you currently plan on including the prefab mapper window in the next update?
     
  45. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    301
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    So yeah, you have more than 4 overlapping lights. Built-in lightmappers would simply force the remaining lights to become fully baked (non-shadowmasked) in this case, Bakery currently just skips them.
    There is no way I can improve it for point lights. 4 lights = 4 overlapping spheres = 4 texture channels. However... I think the overlap test for spot lights is not tight enough (i.e. it doesn't check the actual cone, but rather a bounding sphere). In case you have lots of spot lights, it might help if I fix it. For now perhaps try making less important lights to be fully baked.

    That's the plan. I decided it's actually a better idea to have a "lightmapped prefab" component. If you bake a scene containing prefabs with this component, it would automatically save the !ftraceLightmaps object into them.
     
    Mark_01 and zornor90 like this.
  47. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    Is there a way for me to group them or separate them from the rest? This room im working on is larger than most in my game, If I group 4 overlapping lights would that prevent the others from not baking shadowmask? I'm trying to find some way to keep most if not all the lights I placed to have shadowmask capability.
     
    Last edited: Nov 6, 2018
  48. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Hello,

    We're still getting lightmaps that are huge (4k) but have almost nothing in them, not sure if that was meant to have been fixed from 1.3? Here are just two of the many large lightmaps that have ~60% wasted space that keep getting baked out.
    2018-11-07 13_29_24.png 2018-11-07 13_29_37.png

    On the other extreme... bakes now (since 1.4 at least by our guess) seem to spit out lots (several small ones to each large 4k one) of tiny lightmaps between 32x32 and 128x128. Even if we put the min size to 4k it seems to ignore this. Why are so many tiny lightmaps being created instead of being merged into larger atlases?
    2018-11-07 13_26_43.png

    So, where a scene used to have about 5 lightmaps from 1k -4k, there are now over 30 lightmaps, with the 4k ones mostly empty and dozens of tiny ones! :) Any idea, or any settings we might have overlooked?

    Thanks!
     
    Last edited: Nov 7, 2018
  49. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Shadowmasking is engine feature, and so it is not under my complete control. If Unity renders a shadowmasked light, it will use the same mask channel on all objects it intersects.
    You can probably use the culling mask on the light and separate rooms into layers... but Bakery doesn't respect that currently, although can be easily patched. If you think layers would work for you, I can make a patch for you.

    Yes it was supposed to be fixed. Can you try opening ftBuildGraphics.cs and changing
    const int atlasMaxTries = 100;

    to, e.g., 1000? Will it improve anything?

    Perhaps now you have more LODs than you used to have before? Thing is, Bakery splits the whole scene into "global" scene LOD levels to simplify processing, meaning if you have 2 objects, one with LOD0 at 30% and LOD1 at 50% and another with LOD0 at 30% but LOD at 70%, there will be 3 global LODs (30, 50, 70). Currently global LODs can't share lightmaps with each other, so in this case you would get at least 3 unique maps (or more, if one scene LOD doesn't fit into one map).
    Bakery can also generate small textures due to lightmaps being treated as squares (not rectangles) limitation. That means if you have 6 instances of the same object, it will likely generate 3 lightmaps to prevent stretching and empty holes: one 2x2 and two for remaining objects.
    There is an experimental toggle in ftBuildGraphics.cs that forces it to prioritize lightmap count over empty holes. You can try enabling it, but I found the default mode is preferable in most cases:
    public static bool atlasCountPriority = false;
     
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,344
    Just found and fixed a bunch of errors with light probe generation. They should now be correct and have proper contrast/saturation/directionality.

    upload_2018-11-7_17-28-9.png
     
    Mark_01, CoastKid and RomBinDaHouse like this.
unityunity