Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

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

  1. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,627
    Looks like you have more vertices than the maximum integer value, which is currently a problem in many parts of the pipeline. How many vertices are in the scene?
    You can try using Sectors, perhaps? https://geom.io/bakery/wiki/index.php?title=Partial_scene_baking

    Thanks, tested. Looks like it's caused by instancing. The breads are automatically instanced by the engine, and the probe data is therefore passed differently. Found that I didn't update my shader to some newer changes in instancing macros... fixed it! Please try updating. I'm also attaching the corrected cginc to the post.

    Hmmm... are these skinned meshes by any chance? Unity skips their unwrapping silently. If not, weird, never encountered that (I'm developing my game in 2019.3, so I use it a lot). Can you send me some models like that for testing?
     

    Attached Files:

  2. cfantauzzo

    cfantauzzo

    Joined:
    Apr 8, 2012
    Posts:
    75
    Hi! Bakery's awesome and I love the directional lightmap options. However, in URP, I can't get reflection probes/reflections in general working with any of the provided shader graph directional shaders (trying to use BakeryURPMonoSHSpecGraph specifically). Reflection probes just don't show up on my objects using the shader. Any solutions?

    Thanks
     
    guycalledfrank likes this.
  3. cfantauzzo

    cfantauzzo

    Joined:
    Apr 8, 2012
    Posts:
    75
    Huh, so instead of using the example shaders, I made a new shader in shader graph and ported over some of the nodes from the example shaders, and now I'm getting reflections + all the monoSH goodness. I guess that problem is solved, though I don't know why this is the case. Are reflection probes disabled in the example shaders? Shrug.
     
    guycalledfrank likes this.
  4. Glenarvan

    Glenarvan

    Joined:
    Sep 24, 2021
    Posts:
    1
    Set Ambient Occlusion to 1
     
  5. MiragentStudios

    MiragentStudios

    Joined:
    Jun 14, 2022
    Posts:
    2
    I'm hoping someone here can help me. I've got an irritating problem with Bakery. I'd say about 60-70% of my baking attempts turn out to be total duds. When I bake my lighting it all either turns out black, blue, or green. About 30% of the time it might actually bake my lighting. When I bake lighting I will usually have to re-bake it 3-5 times before I get a proper bake. I've tried deleting the bakery lightmaps and clearing baked data in the bakery utilities. That basically does nothing to fix the problem.

    Here are my Bakery settings. Any help would be appreciated:
    upload_2023-9-29_10-56-4.png
     
  6. riznof

    riznof

    Joined:
    Feb 25, 2013
    Posts:
    2
    Hi! My team has been using Bakery, with URP and the shadergraphs you've released. But we do have an existing game that's on the builtin pipeline and would like to start using MonoSH with that game. However, we don't have tech artists to help us out with shader modifications and were hoping to use Shadergraph with MonoSH on builtin.

    Is there any way we could get this to work?
     
  7. riznof

    riznof

    Joined:
    Feb 25, 2013
    Posts:
    2
    We also have amplify shader if anyone has a solution for that.
     
  8. NoxityGames

    NoxityGames

    Joined:
    Jul 1, 2018
    Posts:
    21
    1. Thank you very much for the instructions!
    2. Regarding ShaderGraph in built-in - yes there is! Mainly for non-technical people or TAs to create shaders, or just simply for faster development. It's genuinely quite awesome, only downside is build times.
     
    guycalledfrank and riznof like this.
  9. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    72
    @guycalledfrank Hi, I have some weird behavior when using baked prefabs in combination with scenes loaded from assetbundles.

    If I bake the prefab with baked normals settings, the included storage looks like this.

    prefab-broken.png


    If i load this prefab into the scene, the scene becomes black like it lost all lightmaps.

    But after searching for a working prefab in our repo I found the solution by changing the dir maps array to a length of 1. Then when loading the prefab, the scene keeps its lightmaps.

    prefab-working.png


    One other issue when loading a lightmapped scene from a bundle, if the scene is not active while it gets loaded, the lightmaps appear twice in the lighting dialog. Don't know if this is an issue.

    lightmaps-twice.png

    UPDATE:
    Looks like I have to put the "emptyDirection" texture into that slot to make it work properly
     
    Last edited: Oct 2, 2023
    guycalledfrank likes this.
  10. ChrisBudden

    ChrisBudden

    Joined:
    Jan 20, 2014
    Posts:
    5
    Unfortunately it's not any specific mesh and it's not reproducible. On one dev's machine nearly an entire scene's worth of meshes will fail to unwrap lightmaps, and on another it's 100% fine. If we take a bunch of meshes that were having issues into a new scene, they sometimes work just perfectly

    I'm definitely thinking this is some horrible Unity issue not a bakery one, but I appreciate the help. Might be our project or scenes are set up weird (They've been around for years and through many versions of Unity at this point)
     
    guycalledfrank likes this.
  11. WhiteAnvilStudio

    WhiteAnvilStudio

    Joined:
    Jan 31, 2019
    Posts:
    2
    @guycalledfrank Hello, maybe you can help me with my problem. I baking lights with SH option. And only in android build (APK), when you switching to another scene by scene load - I get corrupted SH info in materials. Looks like loaded SH info from previous scene. In Editor or if dont load other scene - everything looks good.
    Unity 2022.3.5f1 Android
    Two seperate scenes with different models and other data.
    Every settings looks ok.
    upload_2023-10-2_20-26-56.png
    upload_2023-10-2_20-26-43.png
     
  12. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    80
    hi!, Does bakery has something like unity Lightmapping.BakeMultipleScenes function? https://docs.unity3d.com/ScriptReference/Lightmapping.BakeMultipleScenes.html , supposedly unity split the data per scenes after load all scenes, this way they are able to bake lighting and casting shadows on adjacent scenes.

    I was trying to bake lighting with bakery and when two scenes are on editor they bake the lighting correctly but scenes has duplicated data from each scene.
     
    Last edited: Oct 3, 2023
  13. ChrisBudden

    ChrisBudden

    Joined:
    Jan 20, 2014
    Posts:
    5
    Ok @guycalledfrank some info for you after some more digging on my end!

    Under ftModelPostProcessor.cs, OnPostprocessModel(), Unwrap() you call unity's Unwrapper here:
    Code (CSharp):
    1. var tt = GetTime();
    2.             Unwrapping.GenerateSecondaryUVSet(m, uparams);
    3.             if (m.uv2 == null || m.uv2.Length == 0)
    4.             {
    5.                 Debug.LogError("Unity failed to unwrap mesh. Options: a) Use 32-bit indices and Unity >= 2018.4. b) Split it into multiple chunks. c) Disable 'Adjust UV Padding'.");
    6.                 unwrapError = true;
    7.                 lastUnwrapErrorAsset = assetPath;
    8.             }
    9.             Debug.Log("Unity unwrap time: " + (GetTime() - tt));
    However, I'm definitely seeing meshes that have no UV2's, and no error message comes up, which is an issue in itself. For example, this is one mesh in an FBX model:

    upload_2023-10-4_13-57-55.png

    However this doesn't answer the question of why this is happening. What I didn't realize is that through Bakery, all the unwrap params are set to some incredibly small values in the code here for every mesh with an auto-generated lightmap

    Code (CSharp):
    1. uparams = new UnwrapParam();
    2.             UnwrapParam.SetDefaults(out uparams);
    3.             uparams.angleError = importer.secondaryUVAngleDistortion * 0.01f;
    4.             uparams.areaError = importer.secondaryUVAreaDistortion * 0.01f;
    5.             uparams.hardAngle = importer.secondaryUVHardAngle;
    Many of our models simply fail to unwrap with these parameters, and I'll be honest I don't know enough about atlasing to know why they are so small. I imagine simply changing those values is going to cause The Problems... any pointers on where to go from here?

    (I'll add that we have a disturbing number of meshes packed into a single FBX all over this project. Not my choice)

    UPDATE: Actually it may not be the parameters at all. After un-commenting this log, it turns out the meshes I'm looking at are simply not having an unwrap attempted on them! Turns out this code here may in fact not be fine!

    Code (CSharp):
    1. // Get padding from asset
    2. int mindex = saved.data.meshName.IndexOf(nm);
    3. if (mindex < 0)
    4. {
    5.     Debug.LogError("Unable to find padding value for mesh " + nm);
    6.     // This is fine. Apparently caused by parts of models being lightmapped,
    7.     // while other parts are not baked, yet still a part of the model.
    8. }
    Perhaps defining a hard-coded fallback padding value will solve our issues? It seems to be identical for all our meshes in this FBX. Or would that potentially break some kind of atlas packing calculation down the road?

    Also, any meshes with 0 verts in will break the unwrapping post-process for the entire FBX as Unwrapping.GenerateSecondaryUVSet throws an exception. Why would there be an empty mesh in such a collection? Not a question for me to answer =3

    UPDATE #2:
    Unfortunately I have to report that it seems that our lightmap UVs issue has been most easily fixed by simply commenting out OnPreprocessModel() and OnPostprocessModel() entirely, and re-importing our models! I know this means that Atlas padding won't function correctly, but we weren't using that anyway
     
    Last edited: Oct 6, 2023
    guycalledfrank likes this.
  14. egutentag

    egutentag

    Joined:
    Nov 27, 2020
    Posts:
    14
    When setting lightmap scale to 0.1 or less every mesh render in scene is set to zero.
     
  15. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    609
    I have encountered a problem: every time I finish baking (no matter how small the scene is), Unity occupies almost all of my computer's memory (about 90%), and I have 64GB of RAM. Do I need to adjust any settings?
     
  16. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    609
    Report on Unity 2022.3.8f1
     
  17. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,627
    So yes, AO being 0 kills original reflections and Unity's own ambient lighting. This is a workaround because unlike HDRP/builtin, URP doesn't have a way to override GI specifically in its shader graphs.
    Also unoccluded reflection probes often look pretty bad, shining from every corner (it's one of these annoying artifacts that immediately give away Unity on screenshots...). Usually I keep SH objects with SH specular only and shiny/metallic objects using a different shader with reflections and no SH lightmaps.
    If you still want to have reflection probes in these graphs and avoid double GI brightness, they can be added relatively easily in the graphs. Attached is the SHSpec subgraph used by BakeryURPSHSpecGraph, which I modified to have reflection probes (using URP 14.0.8 here).

    Here is what I added:

    upload_2023-10-10_18-54-10.png

    OK this is weird. Can you please:
    - Try updating your drivers (https://www.nvidia.com/download/index.aspx)
    - Try not using OptiX denoisers (OpenImageDenoise or off)
    - If that doesn't work, DM or email me your GPU name + any error messages present in console + lightmap count (printed to console if you enable Checker Preview). Also does it only happen with one particular scene?

    You can use Bakery Standard shader on built-in, no need for porting the graph (!)
    Or do you have customized shader graphs that go beyond just MonoSH support? Also did you try the existing URP shader graph in built-in? Most of the stuff there is not URP-specific.

    Hmm... perhaps your root scene uses directional lightmaps, but prefabs don't?

    Shouldn't be an issue, unless they are not unloaded when you want to fully unload the bundle.

    Very odd. I don't know if it can help, but just in case, try baking with Asset UV Processing = Remove Adjustments, just to see if the most vanilla unwrap version will look reasonable.

    OK, weird, do you load the scenes asynchronously at runtime? Can you try calling ftLightmaps.RefreshFull() after the scene is fully loaded? Also, does it happen to any scene that is open at the time of building?

    Yeah, it works the same, except the lightmap list is shared across all scenes. I forgot why I disabled the deduplication code, but you can try it and see if it helps. In ftRenderLigthmap.cs there is

    public static bool removeDuplicateLightmaps = false;


    try setting it to true instead of false.

    Hmm, that's a good catch. But how did you import a mesh with 0 vertices? Unity FBX importer completely removes mesh renderer/filter for these (at least for me).

    Interesting, interesting. So if you enable the adjustment, will it fail the same way again with these models? Maybe you can send these magical problematic FBXs to me to test?
    Also the branch you quoted is only called if you used "Save padding to asset":

    upload_2023-10-10_20-53-16.png

    In any other cases, different branches are taken.

    Baking with Asset UV Processing = Remove UV Adjustments would do the same, no need to change scripts. But I wonder if after removing and then adjusting again it will end up in the same weird state?

    ?? I can't reproduce this. Do you mean the values are set to 0 on mesh renderers after the bake?

    After baking Unity usually starts encoding/compressing textures. I didn't check how much memory it takes, but it can easily take a lot of CPU time. Maybe memory as well if you're using "parallel import". You can verify it by selecting all your lightmap texture assets -> right click -> reimport. If it takes the same amount of memory, then it's the reason.
    Although 64 GB sounds like a lot. And does it free this memory later or does it always stay at 90%?
    After some quick tests I can't reproduce it. Does it happen with my examples scenes too? It would be helpful if you could record and DM me a video with the task manager / performance open and the baking progress bar visible, so it can be tracked at which point memory allocations start to grow... if you can also send me a little test project, that would help even more.
     

    Attached Files:

    Last edited: Oct 10, 2023
  18. Object-Null

    Object-Null

    Joined:
    Feb 13, 2014
    Posts:
    68
    hello there,

    how do i avoid this, low quality render on some of the objects?
    for this cabinet/counter i use 2 UV Channels.
    those uvw's are the same in size for the second UV channel


    upload_2023-10-13_11-54-5.png

    this is with shadow checker enabled
    upload_2023-10-13_11-54-21.png

    and this is the default baked lightmap view.
    upload_2023-10-13_11-55-14.png

    i have no idea what i'm doing wrong here.

    hope somebody has a answer for me. thank you in advance
     
  19. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    592
    If you make your own engine, and it happens to be FOSS. You have my support, I'll do what I can to help out.

    Btw your game is looking amazing. Love the brick throwing\breaking windows tweet. :cool:

    Godot support would be awesome. I think most serious indies will be leaving Unity once their current game is done. The only ones left will be the F2P games that are monetizing successfully and probably hobbyists or random students. Which is most likely Unity's target consumer anyways. .. . but don't stretch yourself too thin. You have enough on your plate I think..

    Unreal is just as bad as Unity (esp with the latest round of layoffs by Tim) .. Before Unity came, Unreal had some very predatory business practices.. young devs nowadays won't know this cuz they weren't born yet.

    Ok I'll have to package a light weight version later on. I moved onto non-lighting based tasks again. I have no idea why I'm the cursed one, what did I do in a past life?:D

    This seems to have done the trick. Thanks! :)
     
    Last edited: Oct 18, 2023
    guycalledfrank likes this.
  20. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    59
    Hi,
    I am using bakery with prefabs(not bakery prefabs but just ordinary prefabs set to static), the problem I am running into is that if I use the same prefab across multiple scenes, the last scene that gets baked gets the right light-mapping whereas every scene before that starts showing bugged out lightmaps the prefabs. I believe this bug goes away if I disable the "fix uv" option in the bakery settings, my theory is that this setting is alters the uvs based on the scene data and other objects in the scene, so bakery ends up re-adjusting the uv padding(of the fbx) every time that prefab goes through bakery during a bake, and since no 2 scenes are the same the last-baked scene is the only one that looks correct.
    -we are using auto generated lightmap uvs.
    -we are also using prefab variants.
    View attachment 1318076
    upload_2023-10-16_14-11-23.png
     
    Last edited: Oct 16, 2023
  21. jg3d

    jg3d

    Joined:
    Jan 13, 2014
    Posts:
    17
    Hi, all-

    I'm having difficulty additively loading light mapped scenes without messing up the lightmaps of the added scenes. Everything looks great when loaded independently (see image #1), but is completely unaligned when additively loaded (see image #2). The manual says independent baking and additive loading is possible. Am I missing something?

    Thanks in advance!

    Unity: 2022.3.10 LTS
    Pipeline: URP
    CleanShot_2023-10-11_at_10.09.342x.png CleanShot_2023-10-11_at_10.10.492x.png

    [EDIT]: I think I fixed this by dumping out all the lighting / bakery data/cache for the scene and starting from scratch. There seemed to be something weird in the way it was referencing the lightmaps
     

    Attached Files:

    Last edited: Oct 18, 2023
    guycalledfrank likes this.
  22. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    12
    Hey @guycalledfrank,

    I'm using an Intel i9-13900KF CPU with and RTX 3070 Ti card I can't seem to configure Bakery to push the system to its maximum potential to bake a small sandbox scene of 600m x 600m faster. I also tried setting the tile size to 2048 and I'm using RTX mode.
    The baking process doesn't seem to parallelize the work enough to use all the GPU and/or CPU resources.
    I noticed that Bakery generates multiple temporary LM files one by one. Maybe a stupid question here but is there a way to maybe set it to generate multiple LM at the same time? Or something to allow it to squeeze more of the CPU and GPU resources?
    The overall system is barely getting a pushed during the baking process.
    And for a scene of 600m x 600m with a lot of foliage objects I'm getting something like 30 minutes bake time.
     
  23. nekroraptor

    nekroraptor

    Joined:
    Sep 9, 2018
    Posts:
    1
    Hey @guycalledfrank,
    I have been working with your asset for 1 year in Unity 2020 with success.

    But I had to update the project to 2021 and then it stopped working (I dont know if it´s directly related or maybe another change is affecting).

    With the new version in the same project, if I try to start the preview Unity stucks with this (see attached image).

    I have reinstalled the asset, updated... but still not working... There is something I can do??
     

    Attached Files:

    guycalledfrank likes this.
  24. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,627
    Seems like occlusion, but very low-res. Try increasing scale in lightmap for this object? Also check if disabling "Fix Seams" changes anything? You can also send this scene/model/package to me, and I'll test it and see if there is a better solution.

    Hi! Did you try any of these solutions? https://geom.io/bakery/wiki/index.p..._in_one_scene_breaks_its_UVs_in_another_scene

    Hmm do you have any performance graphs?
    - If you have lots of area lights (Light Meshes), try applying the latest github patch, as I fixed the associated CPU overhead: https://geom.io/bakery/wiki/index.php?title=Github_access
    - If you have a lot of small lightmaps, try this: https://geom.io/bakery/wiki/index.php?title=Troubleshooting#I_get_too_many_lightmaps

    I tested it on 2021, so it should be the problem. Seems stuck on scene export. Possibly atlas packing/unwrapping? https://geom.io/bakery/wiki/index.p...rting_scene_-_preparing.22_is_taking_too_long

    Does it work on smaller scenes or my example scenes?
     
  25. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    76
    FIXED
    Hello, i have an issue with an URP alpha cutout custom shader, when the _BaseMap texture has an alpha channel.
    It looks like there's no GI bounce ? I'm able to get that same "wrong" result with a Unity SimpleLit if the object is fully clipped.
    So it's like Bakery is considering the mesh to be fully clipped, eventhough it is fully displayed.

    It's fine if i remove the alpha from the texture or if i set the RenderType tag as opaque.
    I'm not sure what to set.

    Edit : my clipping variable wasn't named _Cutoff
     
    Last edited: Oct 25, 2023
  26. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    72
    Exactly. We do this so we can later rotate our prefabs which would not work when the prefabs use a directional mode I think.

    Should we bake them differently? Now I set those values via script right before they get initialized, but was hoping for a better solution wich already works during baking.
     
  27. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    86
    Hi @guycalledfrank ! I was checking out the new MonoSH directional map type and after a few tests, I was immediately wondering: Why isn't there an option to save the directional map as 16bit per channel .PNG ? Especially on flat surfaces I had nasty blocks everywhere no matter the compression. So I threw the texture into substance designer and did some dithering, down sampling and blurring and exported with 16 bits and was able to get rid of a lot of the issues. But obviously that technique is pretty limited and cumbersome. Any chance you could give us the option to select bit depth for directionality? (Maybe also a viewport denoiser for rtpreview if you find the time?)
    Keep up the great work :) I love your products. Thank you so much for making them
     
  28. TheOnlyBete

    TheOnlyBete

    Joined:
    Jul 7, 2015
    Posts:
    2
    Hey @guycalledfrank,

    I'm having an issue with Bakery and Unity 2022. As soon as I import Bakery, the scene view breaks. The textures in the scene view don't display, it looks like instead it is showing the lightmap. The skybox also disappears.

    When I close and reopen a scene, I do get some errors - I have screenshots if needed.

    I've tried creating a new project and only importing Bakery but get the same result.

    If I downgrade my current project to 2021.3.31f1 everything works as intended.

    The game view looks fine, this seems to only affect the scene view.

    Is this something you're aware of? If so is there a fix? I've tried getting the latest patch from github and that did nothing for my issue unfortuantely.