Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    14
    Hey there @guycalledfrank!
    New proud owner of Bakery here! ✌ Incredibly awesome package!

    Just to be sure I'm not using it wrong and because I couldn't find anything about this in the docs I have the followiong question.

    Do you happen to know or anyone here knows why baked mesh re-import times increase exponentially when the Bakery package is in the project?

    I noticed if baking a scene with those meshes on my home station Bakery sets up some extraUserProperties in their meta files like padding and stuff. If those meta files changes get committed and pulled back on my work station and the padding changes for some meshes in any way, their reimport time takes 3-4 times longer when Bakery is in the project.

    If Bakery package is removed from the project the same import properties changes applied to the meshes will be done in aprox. 1/4 of the time.

    I'm guessing Bakery is doing some asset postprocessing on those meshes that takes a huge amount of time.
    Can someone confirm or know how to disable this behavior without removing Bakery?
     
    guycalledfrank likes this.
  2. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15
    I've purchased the asset to bake the lightmap on prefabs thta twill be downloaded at runtime and laoded form assetbundles.

    I've put the light in the asset bundle of a scene, then i load the asset bundle and eveithing is working correctly.
    But now I have to deal with the player that is not receivign realtime lights becasue there is no light in scene.

    if I add a realtime light the scene i get the baked lightmap and added the realitime light.

    when i was using unity for baking i would use mixed on lights that will maintain the realtime for non static objects and baked for static objects.

    there is a way to do this in bakery?
    i've serached in manueal but i've not found an answer.

    i've attached an image to better explain the problem.

     
  3. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    137
    Just want to give you a shout, you just saved me from pulling my hair out. Decal feature with Automatic or Dbuffer, or SSOA with After Opaque unchecked is what causes this issue. Clicked all the scenarios to see the actual cause.
     
    guycalledfrank likes this.
  4. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    :eek:
    If you'll have any clues/ideas/possible steps to reproduce it (or it just gets fixed with a Unity update), please report...

    Hmmm can you check if it works in the example_subtractive, and if it does, is there any difference between our light setup?

    Just tested on 2023.1.5, seems to work:

    upload_2023-8-5_17-40-35.png

    Actually looks correct on that last pic? Perhaps the interpolated value is just too coarse and having a bit more probes will make it better?

    upload_2023-8-5_17-41-52.png

    Thanks! :oops:

    Weird! "Update skybox probe" works for me on 2022.1.23 / HDRP 13.1.8.
    This looks like a Unity bug to me: https://forum.unity.com/threads/imp...erated-inconsistent-result-for-asset.1018768/
    Is the asset actually generated? There should a file named like "YourFirstActiveSceneName_SomeNumbers_sky.exr" in the project. As I can see, there are 3 options:
    a) The asset is not generated (?), but the error doesn't look related.
    b) The asset is generated, but importer fails due to some Unity bug. Possibly solvable by reimporting the asset.
    c) The asset is generated AND imported, and the error does not actually affect anything.

    It should fully match your HDRP skies. How does your .exr look? Does it even look similar to the sky (if you check it in e.g. Photoshop with decreased exposure)?

    If you can send me any test project where I can reproduce it, that would help a lot.

    Definitely possible. Like, you can just have normal map used in the Bakery Meta Pass (as shown in Baked_Normal_Maps_meta.shader), but don't actually use it in the main pass :)
    Are the shaders custom/rewriteable?

    ... yeah, like that :) (or you could skip any normal-mapping code from the main forward pass entirely)

    Seems like these example shaders got a bit outdated... I forgot to update them when I changed something in the normal meta pass :( Sorry! And thanks for pointing out. Just pushed a fix (also attaching updated example shaders to this post).

    Technically in this case it would be easier to just change the range, instead of a full match?
    I.e.
    unityLight.range = range;
    bakeryLight.cutoff = range;

    If it's not just about range, I can see how having full publicly callable matching methods would be useful.
    What options do you actually change though?
     

    Attached Files:

  5. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    Hi and thank you! :)

    1. Did you set xatlas as the unwrapper? It can take much longer to unwrap.
    Usually I recommend using xatlas only as the atlas packer, while individual meshes are unwrapped with the Unity one (it's how it's configured by default).

    2. Is there ever such a difference if working on a single machine (not pulling)? I wonder if it runs the import twice when pulling for some reason (maybe if the AssetPostprocessor script was loaded after the model?)

    3. Do you ever manually clean your Library folder? (not something most people do, but I'll ask just in case)

    The quickest "workaround" is to disable UV padding adjustment by setting "Asset UV Processing" to "Remove UV Adjustments": https://geom.io/bakery/wiki/index.php?title=Manual#Asset_UV_Processing
    But then you may need to tweak padding manually for some models if they look leak-y (pack margin): https://docs.unity3d.com/2019.3/Documentation/Manual/LightingGiUvs-GeneratingLightmappingUVs.html

    But actually it shouldn't be noticeably slower (it's literally running the same built-in unwrapper code - just with different pack margin values derived from object size/resolution).

    Yes, you can use mixed lights, e.g. the Shadowmask mode: https://geom.io/bakery/wiki/index.php?title=Manual#Shadowmask
     
  6. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15
    Thanks for the answer @guycalledfrank
    So the mixed mode needs also a direction light from unity on the same object where is placed the bakery light?
    this behaviour works also for other kinds of unity and bakery lights?
    furthermore this works in shadowmask and distance shadow mask but not in subtractive, right?
    Do I need to set the shadowmask, or if it works the subtractive, form the Lighting panel of unity?
     
  7. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15
    I'm also having trouble, if i put the unity directional light set as mixeed with the bakery directioanl light and set the render mode as shadowmask, and bake contribution with Ondirect and Shadowmask (i've also rtried direct, indirect, shadowmask), the directional light is baked into prefab, but the directionalis also lighting the static meshes of the environment. so i can see the directional light that hit non static objects and cast shadows , but it also hit the static baked objects.

    it is possible to make the directional light baked to only hit the non static objects and cast shadows on static baked objects?
     
  8. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    73
    Hi everyone! We updated latest version on GitHub but now all denoisers do not work anymore. Someone has the same problem? I also updated the nVidia Drivers (4070 GeForce Ti) Thanks.
     
  9. alex123456

    alex123456

    Joined:
    Mar 6, 2014
    Posts:
    4
    Thank you for your help. I tested it and it works now.
    However...

    On my tests I found that just by including the _BumpMap property in the shader, even if the shader itself has no references to anything on how to calculate it, Bakery still uses the bump map. Is that correct?
    If so that makes my life so much easier... At least with a custom vertex shader without a meta pass that I tested it works. I wanted to know if I am understanding it correctly.

    On the manual you mention:
    "If the pass is not present, Bakery will assume _MainTex, _BaseColorMap or _Color (if no texture is set) properties as material albedo and _EmissionMap and _EmissionColor as emissive color."
    There is no mention to bump map, but it seems to have the same behaviour. Is it safe to assume the same will happen with metalicity, occlusion and other default properties?

    Thanks!
     
    guycalledfrank likes this.
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    Yes. Note that shadowmasked Area Light + Light Mesh pairs are only supported in HDRP (because only HDRP has real-time area lights). For points/spots/directs it'll work in any render pipeline.

    You can use Subtractive too, but in Unity it only works with 1 directional light, and you need to specify reasonable "shadow color" in Unity lighting settings.

    Hmm are you using Bakery Lightmapped Prefab component on the prefab?
    https://geom.io/bakery/wiki/index.php?title=Manual#Bakery_Lightmapped_Prefab
    It should store lighting information (including light modes) correctly. Regular Unity prefabs without this component do not.

    Can you show me screenshots of your inspector when the light & prefab root are selected?

    Any specific error messages?

    There is no way to know if the shader actually uses it (apart from analyzing the compiled bytecode and constant buffers), and there is no universally agreed property that toggles the normal map either, so... yeah :)

    It's mentioned here: https://geom.io/bakery/wiki/index.php?title=Manual#Normal_mapping

     by default normals are taken from a texture named _BumpMap, additionally transformed by _MainTex_ST.
     
  11. psycoclownagent

    psycoclownagent

    Joined:
    May 8, 2023
    Posts:
    4
    I am sure it has been discussed somewhere already in this forum a while back, but I do want to ask why there is no support for AMD cards.
    A friend of mine (no, really) recently bought a new card under my recommendation and they're devastated that this plugin doesn't work with their new card, or atleast it seems like it.

    It's odd to exclude about 20% of the marketshare in GPU's (Intel not being considered here).

    Is there any chance that you will support it in the future?
    And if not, do you know of any alternatives that do support AMD?
     
  12. NoxityGames

    NoxityGames

    Joined:
    Jul 1, 2018
    Posts:
    33
    guycalledfrank likes this.
  13. unity_E689A8827B3C59AC4AA1

    unity_E689A8827B3C59AC4AA1

    Joined:
    Aug 2, 2023
    Posts:
    12
    Because it relies on nvidia specific stuff. Your friend should have gotten an RTX card if they are serious about doing anything graphics related. This isnt just bakery that does this, this is common across a lot of software in the industry for exactly this reason.
     
  14. psycoclownagent

    psycoclownagent

    Joined:
    May 8, 2023
    Posts:
    4
    That sounds more like the industry needs to catch up with the times and realize that AMD is playing a hard game of catch-up with Nvidia when it comes to ray tracing as that's currently one of the only fields Nvidea is still dominating.

    As far as I can see AMD has an answer currently for every Nvidia specific product or software, albeit less optimized and weathered.

    Besides all that though my friend hit a wall with this plugin only, so that's why I'm asking.
     
  15. unity_E689A8827B3C59AC4AA1

    unity_E689A8827B3C59AC4AA1

    Joined:
    Aug 2, 2023
    Posts:
    12
    This has nothing to do with nvidia, you should complain to AMD and ask why they are not making tech that is compatible with RTX specific software. I am sure you will get the answer that its a lot more complicated than you are making it out to be.

    Either way complaining here is literally going to do nothing, the creator of this asset is not the owner of Nvidia and AMD.

    Saying "well the industry should change then" is great, but what exactly is the creator of this asset meant to do about that precisely? So yeah, be a little bit more realistic mate.
     
  16. psycoclownagent

    psycoclownagent

    Joined:
    May 8, 2023
    Posts:
    4
    RTX is a software and hardware solution thats propietary to Nvidia so it has everything to do with them as they wont allow AMD to touch it.

    AMD has RX in that regard.

    I don't know what you're on about besides trying to answer for the dev.

    The original question is stil if there's going to be any support at all for AMD in the future for this plugin.
     
  17. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,662
    When guycalledfrank started developing Bakery in 2015, only NVIDIA-dependent solutions were available (CUDA and OptiX). There was no AMD alternative for either one available yet. Nowadays, RadeonRays is a thing... but it might lack features that are necessary. I wouldn't hold my breath.

    Past quotes of him (newest to oldest):
    (December 2022)

    (Sepember 2022)

    (June 2018)
     
  18. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    602
    hi @guycalledfrank

    That did the trick! Thanks for the tip ! :)
     
    guycalledfrank likes this.
  19. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    602
    Hi @guycalledfrank

    I was reading this wonderful overview from @kristijonas_unity
    https://forum.unity.com/threads/lightmapping-troubleshooting-guide.1340936/#post-8467559

    Specifically talking about
    23.2.1 Recalculate probe tetrahedra using the API
    You can use LightProbes.Tetrahedralize to recalculate light probe tetrahedra after loading and
    unloading scenes. Wait for the LightProbes.needsRetetrahedralization event to finish before
    making the API call. Upon successful execution, Unity will reintegrate additively loaded probes
    into the tetrahedral structure, and will remove the unloaded probes

    I was wondering if Bakery would also need to call LightProbes.Tetrahedralize and LightProbes.needsRetetrahedralization? I guess the answer is yes? Since Bakery uses the same light probes as Unity's own Baked Global Illumination (GI) solution? :rolleyes:

    What do you think?
     
  20. psycoclownagent

    psycoclownagent

    Joined:
    May 8, 2023
    Posts:
    4
    Fair enough.

    I ofcourse hope he at some point does delve into their stuff.l, but that is at his discretion.
    Friend of mine now has a 4070 instead of the 6800XT I suggested him.
     
  21. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    389
    Hi,

    I'm really struggling with HDRP (14.0.8) and lightmapping in Unity 2022.3.5f1.

    I'm getting these type of results with Bakery:
    c5765bd1b9f58991a3f0d9ce3a7bfe49.png

    I have a single directional light:
    e3f730d9a9c450733cb3b329dd5a4b5f.png

    I'm using a 'Physically Based Sky' and have exposure set to 10 although the sky doesn't affect the lightmap.

    74de86bdb8bf1486fb57cf0519c4768a.png

    My FBX has 'GenerateLightmapUVs' and I have had no problem with UVs in previous bakes.

    This is how the lightmap looks from outside the env:
    ec1c0c5c25153bc06b33087c2216d1ad.png

    There is only 1 directional light being used in the scene.

    Unity lightmapping in HDRP is just such a frustrating experience.
     
    guycalledfrank likes this.
  22. WorkingAlberos

    WorkingAlberos

    Joined:
    Nov 30, 2022
    Posts:
    5
    FIXED: It's now fixed! Thanks to the guy that everybody called him frank. It's just that edge of the model is a hard edge. The artist team soft edged it and it's fine now.

    -------------------------

    Hi, this problem has been haunting me for a while now. Basically, baking result sometimes has seam along what suppose to be a smooth rounded surface.

    Here's the example of what that look like. This cabinet is part of the room model fbx. The room model has "Generate Lightmap UVs" from import setting enabled with the default setting (see image). However, some of the mesh in that fbx has UV1 (custom lightmap UV) but this cabinet doesn't have it. I notice the directionality view seems a bit strange. I ask the modeler to check the normal of everything and if they notice any anomalies but they said everything is fine. I'm lost here, any advice?

    result.jpg

    setting.jpg
     
    Last edited: Sep 6, 2023
  23. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    128
    @guycalledfrank Been using the assets for whole year now.

    I Believe its time you may consider supporting mac for light baking especially with their latest chipset.
    I'm so tired of carrying two laptops just in case if I've to edit the lightmaps or redo any light baking:D

    In fact, I wont complain if you made it and put it on store as another paid asset since it will require tons of work from you
     
    guycalledfrank likes this.
  24. kotoezh

    kotoezh

    Joined:
    May 21, 2013
    Posts:
    21
    Hello
    Thank you for this great tool. We are very happy about switching from standard Unity lightmapper. However we miss a simple feature which affects our project.
    We need to prepare our scene before baking setting Emission property blocks in our objects from the default material emission to custom color. I.e. emissive objects use the same material modified at runtime. To bake correct light we process their property block. We can do it both in edit mode and in runtime, because have direct access to all the loaded scene objects. So built-in lightmapper outputs correct result.

    But Bakery is working with its own instance of Scene we cannot access. So the only way to make it work with different emissive colors is creating a bunch of materials and reassigning them to scene objects, then baking. It is not convenient even using Editor scripting.

    So I wonder if some Callback like OnSceneOpened(Scene scene) could be added to access game objects and prepare their material property blocks for baking?

    Thanks!
     
    guycalledfrank likes this.
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    Good news: today I've added a little, but useful optimization for Light Meshes (aka area lights) that internally combines many of them (given they have identical settings and affect the same LMGroups) into a single mesh, meaning if you have scenes with LOTS of area lights, you can get a significant speedup by removing the light switching overhead.

    On this synthetic test with 500 area lights (each light has 256 far samples and 16 near samples, self-shadow enabled):



    A non-batched bake takes 7 min 18 sec (mostly spending time on switching between lights, i.e. just overhead):



    Batched version only takes 43 sec (note there is also other stuff off screen in this scene):



    ... which is a 10x speedup (!). Of course on a real complex scenes the numbers can be different, but now you can try it with the latest patch :)

    To use the optimization, go to Experimental settings -> Performance and use this slider:



    ------------------

    There are some historical reasons. Bakery uses OptiX API for raytracing: https://developer.nvidia.com/rtx/ray-tracing/optix
    AFAIK OptiX was the first such library in the world and back in 2015 (when the development started) there was no alternative. Later, AMD came up with FireRays, but it was severely limited in comparison. Even later, DXR was designed, using similar concepts to OptiX, but being a part of DX12 (and I didn't want to use it because I wanted it to work on Win7 :D). Even EVEN later (basically last year), AMD came up with HIP, which seems to be a more complete non-DX12-bound solution. It's definitely worth taking a look at, but at this point Bakery has very deep OptiX integration, so translating everything to HIP might be not an easy/quick task.
    It's actually pretty common for graphics software to start with CUDA/OptiX features and then add AMD counterparts later... namely because AMD themselves add support for these features much later.
    "Is there any chance that you will support it in the future" = yes. Do I have a specific deadline for it? Not at the moment. But I'll experiment with it.

    Oh well, you explained it already :)

    Yeah, I know this presentation, and I even tried it :) But there are 3 problems:
    1. There is a LOT of data. 5 lightmaps? 9 lightmaps? I'd rather trade this memory for extra resolution. Even existing SH lightmaps are bit fat, so I added MonoSH as an alternative.
    2. Limited usefulness. Having 9-color SGs won't make diffuse lighting or very rough specular significantly better than existing SHs (and in many cases even MonoSHs). SGs still can't deliver high-gloss specular either. So the only benefit is getting better "a bit less rough" specular; you still have to mix it with cubemap/SSR/whatever to take all roughness levels into account, and often the final difference isn't worth it.
    3. They need fitting, while SHs don't. You can project light into the SH basis and just sample it. Doing so with SGs will violate energy conservation (because of gaussians potentially adding more energy when they overlap each other or leaving darker "holes" when a bright area is left between their centers); meaning you have to render a much higher-quality probe and then use some form of fitting to tweak the colors so they resemble that reference probe when added together. RAD proposed least-squares fitting, which is slow. There is a better, newer method: https://jcgt.org/published/0009/01/02/paper-lowres.pdf
    ...buut it also has some annoyances like "16-bit floating point is insufficiently precise to capture the minute adjustments to the weights" which may potentially result in 2x memory usage during the bake...

    If you have a case where SGs are definitely worth it in your opinion, maybe DM me the details/project, and I'll see what I can hack :D

    When you use Bakery to render light probes, they're just regular Unity light probes that follow Unity logic, meaning that, yes, if you load multiple baked scenes at runtime, you can call Tetrahedralize() to combine their probe grids. Bakery specifically doesn't need to call it.

    Looks like the resolution is very low (barely a texel per whole chair?), can you show me your Checker Preview please?
    There is also a noticeable lack of GI. Are you on the latest store version? What is your HDRP and Unity version?
    As mentioned in my older post:

    Quick check: in ftUVGBufferGen.cs, there is a line:

    Shader.SetGlobalVector("unity_LightmapST", scaleOffset);//(isHDRP) ? scaleOffsetFlipped : scaleOffset);


    Try replacing it with:

    Shader.SetGlobalVector("unity_LightmapST", isHDRP ? scaleOffsetFlipped : scaleOffset);

    If it's the only reason, I'll make a version-based switch.


    You need the Sky Light component. You can match it to your PBS Sky easily: https://geom.io/bakery/wiki/index.p..._use_Skylight_with_a_procedural_sky_shader.3F

    Note that there were some changes in HDRP 14 that made "Update Skybox Probe" generate empty cubemaps. I've added a workaround in the latest patch about a week ago after noticing it: https://geom.io/bakery/wiki/index.php?title=Github_access

    I'm not sure what this huge blob of light is :confused: Maybe fixing other problems will fix that too...

    So in total, my advice is:
    - Apply the latest patch
    - Use "Update skybox probe" to generate a cubemap of your PBS Sky; Add a Sky Light and insert this cubemap into it (leave color as white and intensity as 1).
    - Check your texel density with Checker Preview; tweak Texels Per Unit / Scale in Lightmap until it looks OK.
    - Bake.
    - If everything looks odd, replace that one line in ftUVGBufferGen.cs and rebake. If that helps and everything looks alright, please report your Unity & HDRP versions (and if it doesn't... still DM me with the results please).

    Interesting. Can you send me a unitypackage with this mesh + some light affecting it? I'll check it.

    This is unfortunately even harder than just supporting AMD on Win :)

    Bakery has some events you can subscribe to, perhaps you can use them?
    https://geom.io/bakery/wiki/index.php?title=Manual#Scripting_API

    e.g. OnPreFullRender and OnFinishedFullRender.

    You can get all active open scenes by using e.g. EditorSceneManager.sceneCount and EditorSceneManager.GetSceneAt(i).
     
    Last edited: Aug 27, 2023
  26. WorkingAlberos

    WorkingAlberos

    Joined:
    Nov 30, 2022
    Posts:
    5
    FIXED: See my original question post for solution

    -------------------

    OK, I've sent it to your dm. Thanks for the support.
     
    Last edited: Sep 6, 2023
    guycalledfrank likes this.
  27. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    73
    Both myself and a friend can no-longer bake after the most recent patch (completely unrelated projects). It tried to start and then throws this error:

    upload_2023-8-28_14-55-2.png
     
  28. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    73
    Looks like this is caused by setting the new batching option to anything other than 0.
     
  29. stoppo

    stoppo

    Joined:
    Jun 11, 2017
    Posts:
    8
    Hi, I recently moved a project to URP, not realizing that for bakery volumes, shadowmask had limited support.
    compatibilitygraph.png

    I wanted to ask (and with no pressure at all, just wondering), will shadowmask bakery volumes ever be as 'plug and play' in URP as they were in the built in pipeline, and without the 1 directional light limit, or is this just a inevitable limitation because of URP & how shader graph works as said in the docs?

    urpshadowmask.png

    either way, thanks for making an amazing asset
     
    guycalledfrank likes this.
  30. NoxityGames

    NoxityGames

    Joined:
    Jul 1, 2018
    Posts:
    33
    Thank you for your answer!
    The main reason I'm asking for SGs is because of their nature of respecting specular occlusion and directionality much better than the standard Unity reflection probes, with SH however often not delivering enough specular information to create appropriate specularity.
    I would like to completely cut out reflection probes out of my rendering, at least above a certain level of roughness. SH lightmap specular seems very promising for that, but there are a couple things I'd need to make it work:
    1. Support for directionality and specular from volumes OR the ability to only use lightmap specular for static objects and use reflection probes for dynamic ones,
    2. Ability to switch between reflection probe (cubemap) and lightmap specular with a roughness threshold.

    Unfortunately Unity's reflection probe checkbox on the mesh renderers only function in Forward, which doesn't work for me as I'm using a hybrid rendering setup (indirect lighting and mixed lighting handled by lightmaps, layered with lots of realtime lights and realtime higher-frequency lighting such as AO). This is also why I wasn't as concerned about memory usage for lightmaps - since in my case they are quite low resolution since they only need to capture rough indirect lighting.
     
  31. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    389
    @guycalledfrank thanks for the response. I'll work through your list and report back when I have some time to look into this once again. Thanks!
     
    guycalledfrank likes this.
  32. morfevs

    morfevs

    Joined:
    Dec 21, 2016
    Posts:
    19
    Question 1)
    (Problem: jagged shadows i have).

    Bakery shaders could improve the Bakery results. My problem is that when I choose one, it goes pink. How do I use Bakery shaders? (URP 2021.3.13 LTS)

    Question 2) I read from your wiki that using "Bicubic Interpolation for Lightmaps" could also help to get better results. I tried to apply it to get an error message: "UnauthorizedAccessException" I went to Unity hub and started ad admin but the result was the same.

    How do I enable "Bicubic Interpolation for Lightmaps" from the Shader Tweaks menu?

    Thanks in advance for anyone that could help me with this issue.
     
  33. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    Ouch. Can you select this first error and copy the whole message from the log? (DM me pls)

    URP didn't have shadowmasks until recently, and, yes, the graphs are pretty limited (e.g. there is no injection point for shadows), but it's 100% doable.

    SO, I decided to try it right now. Turns out, URP has very neat API for lighting! Comparing to Built-in, it's a huge improvement. Although I had to read an old blog post with deprecated API, a web-archive'd newer blog post that is down because it was posted on "connect.unity.com" which is now also deprecated, a few forum posts and figured it out in the end :D
    Try this:
    https://drive.google.com/file/d/1CIM7_LFaMJ2lxs4eZMZ-KgX8OA7KBt2U/view?usp=sharing

    I've added a new graph called BakeryURPVolumeShadowmaskMultiLightGraph :eek:

    It applies the GI volume, as well as all volumetric shadowmasks for all lights. Here is a comparison with the old shader:

    upload_2023-9-4_14-50-47.png

    I didn't add specular/glossiness for now... but I will. Tell me if it's super critical for you project, so I feel more pressed to add it :)

    You can do that already, just by using a different shader. E.g. if you'll use Bakery shaders, enabling Lightmapped Specular will automatically disable reflection probes. Should work in deferred too.

    I did a similar thing in my game, albeit in a hacky ad-hoc way... you can only use SH on a very high roughness. Mainly it solved wet roads looking too bright in dark corners. Maybe you can try something like that first?

    You can't use shaders for the Built-in rendering pipeline in URP. Unpack Bakery_ShaderGraphURP.unitypackage and use the graphs instead.

    ... I didn't add bicubic filtering to URP though, it's a bit trickier.

    Apparently it happens if Unity is installed to an unwriteable folder, such as Program Files. You need to launch Unity as admin without the Hub (maybe temporarily rename Hub's exe, so it's never called).
    I should really add a proper error message with proper instructions...

    Also as far as I remember it still doesn't affect URP, as it has its own lightmap sampling methods.

    You can also increase Shadow Spread on the light to make shadows blurrier; and if it's a directional light, you can enable the Anti-Alias option.
     
    stoppo likes this.
  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    I've just found an issue likely causing it in your case and fixed it. Can you try patching it again?
     
  35. stoppo

    stoppo

    Joined:
    Jun 11, 2017
    Posts:
    8
    Oh wow thanks, a quick test shows its working pretty much as you said as far as I can tell. Thanks a bunch.

    yeah eventually specular would be cool, but its not pressing at all; I'm just a lone guy trying to figure out an sustainable artstyle for a project, theres no huge urgency on my end. thanks again : )
     
    guycalledfrank likes this.
  36. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    14
    First I would like to apologize for the delayed reply regarding the reimport issue.
    I managed to better clarify the steps to reproduce the issue with the info provided by @guycalledfrank to also workaround it.

    Not sure how to do that. But I did enable UV Adjustments and set xatlass as the packer

    Managed to figure out the cause from your reply. See below for details

    Yep. Tried cleaning the Library folder and the issue was still happening.

    It seems the issue was happening when changing any import settings in Unity (ex: "Import Cameras") for a mesh that had bakery custom padding properties in the meta file. When applying the import settings, that mesh would take up to 5 minutes for the settings to apply instead of a second or two.
    That's what's also happening if you would pull changes from one computer to another and re-open Unity to import the new changes.
    Like you @guycalledfrank pointed out, it's because of the "Adjust UV padding" option being enabled for "Asset UV processing". For some reason it messes up the Unity importer but not sure why. Maybe it's a known Unity issue with the importer.

    The workaround solution is exactly what you pointed out: to remove the custom UV padding adjustments from the meta files either manually or by applying "Remove UV adjustments" option. Now importing works as expected.

    Many many thanks @guycalledfrank !
     
    Last edited: Sep 6, 2023
    guycalledfrank likes this.
  37. VarisMessenger

    VarisMessenger

    Joined:
    Sep 6, 2023
    Posts:
    2
    Hi, the bakery/standard materials flickers on non static objects when the same material is used on multiple non static objects. It only happens after baking. Is there any way to fix it?
     
  38. vchedeville

    vchedeville

    Joined:
    Jun 1, 2022
    Posts:
    5
    Hi, I have two issues with bakery material using volume
    • I use Shadowmask baking with no volume compression and volume with support rotation.
    • Unity 2020 Built-in.
    • Bakery 1.95
    First Issue :
    I have NaN value on mesh using volume lighting and it causes black spots with the custom compute bloom we are using
    https://docs.unity3d.com/Packages/c...g-Propagating-NaNs.html#finding-nans-and-infs
    For performance reasons, we want if possible, to keep the Stop NaN propagation turned off on the PP
    So do you know what causes those NaN values and if it's possible to fix them?

    Second Issue :
    On Intel Graphic Card (A770) objects using volume lighting have big artifacts, those artifacts are not present if the anisotropic filtering is turned off
    upload_2023-9-6_17-12-35.png
     
  39. ChrisBudden

    ChrisBudden

    Joined:
    Jan 20, 2014
    Posts:
    5
    @guycalledfrank
    Hey-o, I appreciate this is a little vague but we're running out of ideas
    Unfortunately we're on Unity 2019.4.31f (We're in VRChat) , so I appreciate this may be a Unity thing

    We've had issues with Lighting UVs being... off or not generated at all in the past

    We're getting some objects with strangely dark lighting. In this extreme example, we have two identical tables, one completely dark in the lightmap!

    I'm assuming this has to be an atlas packing or UV setup issue. Unfortunately when we mess with settings, different objects throughout the scene go dark after a build, so it's hard to pinpoint, but we always seem to get this somewhere in the scene

    We've reset Bakery settings to as close to default as we can for our scene setup

    Was just hoping you/someone might have seen this issue before and have some tips for us =)


    upload_2023-9-6_22-36-8.png
    upload_2023-9-6_22-38-47.png
     
  40. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    602
    Ok thanks for the confirmation. Time to go test this out :cool:
     
    guycalledfrank likes this.
  41. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    602
    Hi Frank,

    Unity 2021.3.24f1

    I lost my bakery lightmaps again. :(:(Took about 4 hours to bake and it looked great, but after exiting Unity and coming back the next day the lightmaps are all lost. :oops:

    I see a red error with: Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1565)
    (Below I pasted the console log)

    Do you know if this is what's causing it?


    .. the weird thing is .. in my test scene the lightmaps are still intact.


    Also there's two things I noticed. :rolleyes:

    [ LIGHTMAPS MISSING ]

    1st level - The lightmaps are not listed after restarting Unity.
    upload_2023-9-10_17-0-40.png

    Test level - The lightmaps are still listed after restarting Unity.
    upload_2023-9-8_15-46-16.png


    [ LIGHT MAPS NAME AND LINKING ]
    The lightingdata is still not the scene's lighting data file. Not sure if this a concern. Should the Light Data Asset be named World1Level0_A_371857150_probes? Currently its called LightingData
    ezgif-4-0ca79239ef.gif


    ezgif-4-df15447af6.gif


    [ DRAG IN FILES - REFRESH HDR FILES ]
    I was testing if the lightmaps .hdr files would get added if I dragged in a new lighting data file. It didn't work.:(
    ezgif-4-397f7b3085.gif

    Thanks for your help! :)

    Code (CSharp):
    1. ArgumentException: Getting control 12's position in a group with only 12 controls when doing repaint
    2. Aborting
    3. UnityEngine.GUILayoutGroup.GetNext () (at <04b2664316804d17bf325b884567dc2b>:0)
    4. UnityEngine.GUILayoutUtility.DoGetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <04b2664316804d17bf325b884567dc2b>:0)
    5. UnityEngine.GUILayoutUtility.GetRect (System.Single width, System.Single height, UnityEngine.GUILayoutOption[] options) (at <04b2664316804d17bf325b884567dc2b>:0)
    6. UnityEditor.EditorGUILayout.Space (System.Single width, System.Boolean expand) (at <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    7. UnityEditor.EditorGUILayout.Space () (at <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    8. ftRenderLightmap.OnGUI () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:1565)
    9. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    10. UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    11. UnityEditor.DockArea.OldOnGUI () (at <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    12. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    13. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    14. UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    15. UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Single pixelsPerPoint, System.Exception& immediateException) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    16. Rethrow as ImmediateModeException
    17. UnityEngine.UIElements.UIR.RenderChain.Render () (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    18. UnityEngine.UIElements.UIRRepaintUpdater.Update () (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    19. UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    20. UnityEngine.UIElements.Panel.UpdateForRepaint () (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    21. UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    22. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    23. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    24. UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    25. UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <1aaa12d3c5d64d42836d89caff78b60b>:0)
    26. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <04b2664316804d17bf325b884567dc2b>:0)
    27.  
    28.  
     
    Last edited: Sep 10, 2023
  42. r_chevallier

    r_chevallier

    Joined:
    Apr 20, 2014
    Posts:
    31
    Recommendation wanted regarding upgrading GPU card Specifically For Bakery Performance!

    Current GPU: GeForce 1070 GTX

    I want to upgrade GPU and am thinking about GeForce 3060 12GB vs. GeForce 4060 8GB.

    Both are around $300.00. Even found a 2 fan version of the 3060 12GB for $225.00.

    GeForce 3060 has more v-ram but the GeForce 4060 is faster.

    I am thinking the GeForce3060 is better for Baking because it has more v-ram.

    Thanks
     
  43. AliaksandrMarachkin

    AliaksandrMarachkin

    Joined:
    Oct 9, 2016
    Posts:
    3
    Hello, is it possible to slowly asynchronously bake some shadows of primitives or simple meshes in runtime on mobile phone, or all should be bake only on PC and added in build? thx
     
  44. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    602
    ##Update## --- Any plans to port Bakery to Godot? :D:D -- just kidding



    Hi Frank,

    I couldn't paste any more images. So started a new message.:rolleyes:

    Last time I was asking about publicly exposing Match Light to Material
    upload_2023-9-10_18-14-49.png

    And you suggested I match the bakery component settings to the light component settings, via code. This is what i came up with.

    Code (CSharp):
    1.  
    2.     [ContextMenu("--RUN SCRIPT--")]
    3.     public void RunScript()
    4.     {
    5.         _bakeLightMesh = GetComponent<BakeryLightMesh>();
    6.         _bakeLightMesh.color = _renderer.sharedMaterial.color;
    7.  
    8.         UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(gameObject.scene);
    9.         UnityEditor.PrefabUtility.RecordPrefabInstancePropertyModifications(this);
    10.     }
    For the most part it works the first time I initialize the method, via context menu.
    upload_2023-9-10_18-17-49.png

    But after I press bake, Bakery reverts back to the original values.
    upload_2023-9-10_18-18-36.png

    Do you know what is causing that? :oops:
    Thanks again for your help! :)
     
    Last edited: Sep 13, 2023
  45. NoxityGames

    NoxityGames

    Joined:
    Jul 1, 2018
    Posts:
    33
    This does not seem to be the case. Here, all geometry uses lightmap specular:
    upload_2023-9-11_0-24-59.png

    However, if I now enable a reflection probe:

    upload_2023-9-11_0-25-32.png

    It looks especially bad on the leaves, with the floor also showing some bad artifacts when looking from further down:
    upload_2023-9-11_0-27-1.png

    So it seems that reflection probes do in fact even affect Bakery shaders with lightmap specular.

    Would it be possible to get that as a feature on the Bakery shader?

    Also, unrelated - is it possible to use ShaderGraph in builtin with Bakery features? Do the provided URP graphs work or something like that, or would dedicated support be necessary?
     
  46. yosimba2000

    yosimba2000

    Joined:
    Jun 3, 2021
    Posts:
    25
    Hi Mr. F, I know it may not be commercially viable right now, but have you considered porting Bakery to Godot game engine?
     
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,658
    One person just asked me today if it's possible to get separate ambient occlusion maps from Bakery without doing a dedicated "Ambient Occlusion only" bake pass. Well, technically yes, it is! I just didn't expose it, because in Unity AO maps are normally mapped using un-transformed un-atlased UVs, unlike lightmaps. However, if you're using your own shaders, or if you don't use default auto-atlasing (Original UV lightmap groups FTW), then it could be useful for you.
    I've just added a little script that let's you fetch AO maps after a normal bake: https://geom.io/bakery/wiki/index.php?title=Community_extensions#Get_AO_Maps

    upload_2023-9-18_10-25-21.png

    ---

    So yeah, regarding this whole Unity situation:
    - Bakery is still on the Asset Store.
    - Bakery for Unity will be maintained and updated as usual.
    - I'm still making my own game with Unity = using Bakery all the time = can't ignore any issues with it. At this point if I'm going to switch engines, it'll be my own engine that I could make extremely Unity-compatible, but it's a whole different story for a different time :D
    - I will, however, look into making a Godot port too. For real, no kidding. Won't make an Unreal one though :D

    ---

    I just mean this is slow and if you're using it, try switching to default:
    upload_2023-9-18_10-35-48.png

    5 minutes is a lot though... Technically it should only run the same unwrapper that Unity runs anyway, but with different parameters. Maybe Unity skips the unwrapping process if you change unrelated settings, unlike my AssetPostprocessor? I was pretty sure it does it every time, just like with texture compression on texture assets. Weird...
    If you still have some assets using the UV adjustment, can you copy any lines from the Unity console that appear after the asset reimport? It should log some unwrap timing stats.

    Never seen that before. Does it happen in my example scenes too? Or does it depend on something else in the scene? Can you send me a little test project to debug it?

    Are you using denoising on volumes? If so, can you try OpenImageDenoise 1 or 2? I noticed OptiX sometimes producing weird colors on low-res volumes. Does it happen at all without denoising?

    Wait, do you force anisotropy on the volume itself? Or is it globally forced in the driver? Seems excessive. You don't need it there as it doesn't have mipmaps anyway.

    Your checker preview looks super low-res, as if there are just 1.5 texels covering the whole table :) So it's unsurprising. Use a higher Texels Per Unit value or increase Scale in Lightmap on these objects.

    The error is unrelated, it's just some Unity UI issue... I still don't understand what's going on here :( If you can send me anything I can test/debug again, I'll check it. Maybe you can make a lightweight version of your problematic scene that still has the issue? It'll probably reproduce without any different materials, scripts, etc.

    Hard to choose. Depends on your typical scene sizes. I'm using 3070 8GB for now, and I never went out of memory yet, so I think 4060 should be good. But if you're baking 100km2 open worlds, maybe VRAM is more important :D

    Bakery runtime can't run on mobile, so they should be prebaked and added to the build, yes. For simple shadows it might be easier to render regular shadowmaps; in fact, if you don't need object self-shadowing, you can even render just a black'n'white object silhouette to an R8 texture, should be super cheap.

    Huh. Maybe try this:

    EditorUtility.SetDirty(_bakeLightMesh);


    Hmm yes, you're right, sorry.
    In forward you can disable probe reflections:

    upload_2023-9-18_11-23-14.png

    ...but it won't work in deferred. The reflection is applied in deferred, outside of the material shader itself.
    If we don't care about deferred specular (only LM specular), we can hack the shader a bit to output zero specularity when "Reflections" are off.

    Add a shader feature to the Deferred pass:

    upload_2023-9-18_11-37-54.png

    Then, at the bottom of Bakery.cginc add this:

    upload_2023-9-18_11-38-25.png

    This way LM specular will be calculated and written to emission, while deferred reflections/specular will be off.

    I never tried ShaderGraph in built-in TBH. Is there a reason to use it when you have Surface shaders? :)
     
    Last edited: Sep 18, 2023
  48. MaxGeorg

    MaxGeorg

    Joined:
    Nov 23, 2021
    Posts:
    4
    Hey @guycalledfrank,
    first super nice Plugin, works very well.

    Currently, we're creating a big factory with lots of accurate machining stations. Sadly, vertex reduction is no longer an option, because of the required accuracy.
    Now we're running into baking errors, because of the too detailed topology. I will attach the related Error messages as screenshots. We're currently using 3090 workstations, so they are somewhat beefy.

    Is there something like an incremental rendering? Like first, we select the 1st third of the factory and render it, than the 2nd third and so on?
    Or what is the advised or your workflow when working with lots of detailed static meshes?

    Thanks for your time,
    kind regards Max

    upload_2023-9-18_14-57-8.png upload_2023-9-18_14-57-17.png upload_2023-9-18_14-57-23.png
     
    guycalledfrank likes this.
  49. VarisMessenger

    VarisMessenger

    Joined:
    Sep 6, 2023
    Posts:
    2
    It needs some light probes to happen. Tested in Unity 2022, 2020 and 2019. Here's some test in example_directional_SH scene: [Removed]
     
    Last edited: Sep 29, 2023
    guycalledfrank likes this.
  50. ChrisBudden

    ChrisBudden

    Joined:
    Jan 20, 2014
    Posts:
    5
    Hi again, that did help with those tables specifically, so thankyou!

    However it seems like we have a much worse issue, which is that Unity 2019 simply fails to un-wrap some models' light map UVs correctly, and just doesn't bother, leaving only the base UVs which have overlaps and therefore create useless baked data. When this happens it also seems to increase how often we end up with some objects being tiny in the atlas, so there's definitely some bug on Unity's end here

    We tried the alternate experimental unwrapper, but it can take upwards of 2 minutes even for a simple model, so that's not really an option for rapid development

    At this point we're going to wait until VRChat upgrades to Unity 2022, since 2020+ had some huge changes to the lighting systems. Will let you know if it fixes things for us!
     
    guycalledfrank likes this.