Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. 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. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Thanks for your help. Yep, that does sound like it is indeed the issue. I'll give it a shot tomorrow and see if it makes a difference. Thanks!

    Ben
     
  2. Obsineon

    Obsineon

    Joined:
    Jan 21, 2018
    Posts:
    10
    Hey, I have been struggling with Bakery lately. Shadows act really weird with low poly models. All the shadows deteriorate and create an unnatural look. Even though Unity bake is slower, it gives better results with just 1024 texture size.

    So I want to ask if you can suggest some settings or advices for baking low poly objects. Espically to prevent those shadow artifacts on specific lines of the meshes.

    I would really like to utilize your asset so any help would be appreciated. Thanks in advance.
     

    Attached Files:

  3. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Do you mean pixelation on edges or some weird stuff going from inside the cliff on the ground?
    Any comparison with Unity bakes?
    If you want really hard edges between the polys, you can:
    - Disable Fix Seams (in advanced settings)
    - Split lightmapping UVs between polys, so they don't share an edge in the texture. If you're generating UVs in Unity, you can try setting Hard Angle to a small value.
     
  4. Obsineon

    Obsineon

    Joined:
    Jan 21, 2018
    Posts:
    10
    Thanks for the fast response.

    Disabling fix seams and reducing Hard Angle to 5 on Lightmap UV generation made them better. It prevented the tearing effects on the lines but there are still some weird artifacts on where two meshes intersect. Or low poly mesh intersecting with the Unity Terrain.

    HardAngleandNoFixSeam.png
    HardAngleandNoFixSeam2.png

    Also for comparison, I baked one with the Progressive-GPU on Unity with 40 texels, 1024 tex size and I am happy with the results. The screenshot of the bake results for both are attached.

    UnityRender1.png

    UnityRender2.png

    I don't understand why it gives better results with the same settings. I would appreciate some explanation. I am pretty newbie on graphics related stuff and after been struggling with Unity Bake, I bought your asset. And now I am using the new Progressive-GPU instead of Bakery, so it is kind of frustrating to me :)

    I hope you understand. Thanks in advance.
     
  5. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    The first screenshot mostly has texture compression artefacts, and you appear to have ambient occlusion enabled in Progressive, so that probably hides them there. You can try disabling texture compression on final lightmap assets just to check the difference and enabling ambient occlusion to darken the contact (advanced settings) with settings similar to Progressive.
    Some light blobs leaking out from the point of contact is likely unrelated. If they don't disappear with compression disabled, there must be something wrong with the leak fixing phase - it would be super helpful if you could cut a problematic piece from this scene and send it to me for debugging.
     
  6. deltamish

    deltamish

    Joined:
    Nov 1, 2012
    Posts:
    58
    Any Bakery Vs Unity PLM comparison with respect to quality and speed ?
     
  7. Obsineon

    Obsineon

    Joined:
    Jan 21, 2018
    Posts:
    10
    Changed the settings you have mentioned and rendered with these settings with Ambient Occlusion on and compression disabled.

    bakeryAndLightingSettings.PNG

    But still, same problem keeps happening. Purple and red light artifacts are still there and intersections are still bad.

    result1.png

    result2.PNG

    I will try to send you a part of my project if I can manage to do so.
     
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Not these settings - they are only relevant to Progressive.
    The ones I mean are texture asset settings:

    upload_2019-1-13_19-12-12.png


    You don't have to re-render anything - just mass-select->change->apply.

    I'll try to do something illustrative when I have time. For now you can ask the users/read the thread/read the reviews.
     
    deltamish likes this.
  9. Obsineon

    Obsineon

    Joined:
    Jan 21, 2018
    Posts:
    10
    I know, I changed them to no compression in those screenshots too. I messaged you this scene as a Unity project with the assets and models in it. I am hoping that it will be easier if you can see it in first hand.
     
    guycalledfrank likes this.
  10. Deusald

    Deusald

    Joined:
    Feb 11, 2014
    Posts:
    31
    What is the status/progress of putting bakery in a different folder?
     
  11. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    It's not there at the moment, but it still on the priority list, and it will be released with the next update. Should happen this month.
     
  12. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    190
    Can anyone suggest a blob/ fast shadow projector that will work with the bakery? I am hoping to use only baked lighting, but need some sort of shadow for NPC. (For mobile VR, so needs to be pretty lightweight).
     
  13. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Is there probably an HDRP LayeredLit for SH and RNM Directional around?
     
  14. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    I think this question is not specific to Bakery - at runtime all you get are regular lightmaps (unless you're using RNM/SH).
    Standard shadow projectors are fine if you don't have too many objects. Last time I checked they worked by re-drawing affected geometry with different shader/blend, so might slow you down if there are lots of them.
    A cheaper method I often prefer is to create a white texture and draw dark blobs into it every frame, then use a modified shader that samples the texture using XZ coords instead of UV.

    Not there yet - I haven't touched the Layered shader yet.
    HDRP shaders are a pain in the ass to change. They use dozens of include files, and I had to add small changes to lots of them just to implement a simple feature.
     
    tcmeric and Mark_01 like this.
  15. MU-TH-UR

    MU-TH-UR

    Joined:
    Aug 16, 2016
    Posts:
    20
    @guycalledfrank I was rendering tests with a shadowmask earlier and they went fine besides some errors with some LOD's and prefabs but now can't even render those without getting this error at the finished rendering pop-up that also when you cancel just loops and pops back up with a 125% or something number instead of 100%.

    Unity 2017.4.17f1 (64-bit)

    NullReferenceException: Object reference not set to an instance of an object
    ftRenderLightmap+<RenderLightmapFunc>c__Iterator2.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:4111)
    ftRenderLightmap.RenderLightmapUpdate () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:2549)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:127)
     
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Weird. Are you also using dominant direction mode? Seems like it's expecting some directional texture to be present, but it doesn't exist.
    First, check if your hard drive is not full. If it's not the case... I think I might have fixed something related to it recently. I can't send the current mid-development version (kinda messy/untested), but as a simple workaround, just try opening ftRenderLightmap.cs, and adding these two lines:

    upload_2019-1-15_13-21-52.png
     
  17. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    bakery light mesh
    first time I'm exploring options with this script , I noticed when I matched the material to light mesh that it switched to Unity bakery light shader. any suggestions other shaders that could work with this or does it require the bakery shader ? I would love to find a bakery shader that supports tessellation , most of my map is currently build around using Beast2018 shaders. not certain if you did any testing with this or could give any suggestions as I start to look into lighting this world
     
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Light Mesh doesn't really care about the shader. The "match material to light" is only for convenience - e.g. if you want to be 100% sure the brightness of the light in the lightmap and in the game or in reflections is exactly the same. Lightmapper will read settings from the component anyway.

    Which features of Bakery shader do you need?
     
  19. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    Which features of Bakery shader do you need?[/QUOTE]
    ah I am still learning please excuse me, I was just confused a bit when I applied match material to light it auto switched the shader… got it now ...
     
  20. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I personally enable mipmap generation on Lightmaps in order to use Unity's dynamic texture streaming (wich works loading and unloading mipmaps)
    However I set the lightmaps mipmap bias to -7 , that way, Unity can asynchronically load the lightmaps progressively without stalling the gameplay but once all mipmaps are loaded, only the base texture will be used, avoiding mipmaps artifacts.
    I do all of this on an AssetPostprocessor script along with setting textures properties and compression by the filename.
    Code (CSharp):
    1.                 textureImporter.mipmapEnabled = true;
    2.                 textureImporter.borderMipmap = true;
    3.                 textureImporter.streamingMipmaps = true;
    4.                 textureImporter.streamingMipmapsPriority = 10;
    5.                 textureImporter.mipMapBias = -7f;
    6.                 textureImporter.anisoLevel = 0;
    7.                 textureImporter.mipMapsPreserveCoverage = true;
    8.  
     
  21. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Clever trick!
     
    atomicjoe likes this.
  22. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I'm currently using EasyDecal for this specific purpose.
    It's not a blob shadow asset, but it works the same way, manages creased edges perfectly and is very fast.
    I use a cube projector and a custom script that casts a ray to the floor under the character in order to set the maximum distance the projector should go and the opacity of the decal material.
    Works wonders for me, but if you want a specific blob shadow solution or you are not a programmer, maybe you should consider other specific solutions like FastShadowProjector. Seems great but I haven't tested it.
     
    tcmeric and guycalledfrank like this.
  23. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
     
    guycalledfrank likes this.
  24. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    could you give a little insight what is happing when you press "Update skybox Probe" in the render section of bakery, I didn't see any info on it in the manual or I missed it

    thanks
     
  25. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Yeah, me neither.
    Maybe it's related to the general environment skybox Unity generates to use when there is no other reflection probe around?
     
  26. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    It just calls DynamicGI.UpdateEnvironment. This, in turn, updates the default diffuse ambient probe (skybox dynamic lighting).
    In the upcoming version it now also updates the default specular probe as well (skybox cubemap for reflections) - not sure how I missed this one before.
     
    Mark_01 and atomicjoe like this.
  27. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
     
  28. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    Hi,
    Is it possible to have lightmapped prefabs to cast shadows into the lightmaps of other objects? Right now if I remove the static mark on the lightmapped prefab objects the light mapping ignore it during the bake and I get no shadows, If I mark it static, it gets overwritten.
    I have a scene with a large amount of tree-like objects and I would want to just have one lightmap on all the trees. IS that possible?
     
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Should be possible, yes. Leave the static mark on, but also remove "enable baking" checkbox from the lightmapped prefab - this will ensure it's not overwritten.
    On top of that, setting Scale In Lightmap to 0 on the trees (but NOT applying changes) will likely make baking faster.
     
    atomicjoe likes this.
  30. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    Ok , I will try that as well. Another question I had was how to add the vertex lightmap feature into my own shaders. I make shaders using ASE.
     
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    I don't know what is ASE, but you can take a look at ftSimpleVertexLM.shader included in Bakery. This is a simplest unlit shader using vertex lightmaps, so should be easy to understand how it works.
    Basically you just read vertex color and decode using this formula:

                    // Decode baked HDR vertex color (RGBM)
    o.color = v.color.rgb * v.color.a * 8.0;
    o.color *= o.color;


    o.color can be now used as final lighting value.
     
  32. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    ASE = Amplify shader editor.
    maybe I can ask the ASE people to have a node for that if possible.
     
  33. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Damn that's nice, where is the "-7" coming from? Is that to counteract the number of generated mips? I tried this and noticed that there were still seams but they looked a lot better, I noticed that my number of generated mips was 12 so does that mean -12 would counteract it completely? Don't have time to try that out at the moment as we are winding towards a release
     
  34. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    I really need some help here. I have a couple of issues.
    1st: Bakery is turning most of my trees white, and I cannot figure out why.
    White Trees.PNG

    Now, if I go to the bottom of unity's lighting tab, and hit "clear baked data", the trees turn normal again. But, every time I hit "play" in the editor, this happens:

    Bake Paused.PNG
    The editor is attempting a "bake" and it turns the trees white. I then have to hit play, and clear the data again. This happens every time I hit play. Auto generate is not turned on, and when I uninstalled Bakery, this stopped happening. I reimported Bakery, and my trees instantly turned white, and auto baking started happening in the editor again, even though it is not checked.

    Also, when I imported Bakery the second time, it turns my entire scene really bright. Simply importing Bakery does this, and I cannot figure out how to fix it. If you have any ideas, I could really use the help.
    Thank You,
    Valerie
     
  35. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    Hi,
    I am trying to understand what the min max resolution is really for?
    It was my understanding that
    <object surface area*texl per unit=pixels inside the lightmap>.
    So if I have a 10x10 plane, at 20 txl per unit, it should take 200x200 lightmap.
    however in bakery, if I crank up the max resolution to 4096, that same object is taking up to 3k in a 4k lightmap.
     
  36. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    What are trees? Are they regular meshes? Do they have Lightmap Group components? Special materials? What makes them different from the rest of the scene?

    How comes your editor tries to bake anything via built-in lightmappers if you don't have "auto generate" on and don't hit the Generate button? Is it possible that you have some third party editor scripts calling the built-in bake?

    It shouldn't be on, or Unity will constantly attempt to overwrite lighting. In fact Bakery disables the checkbox first time you open its window.

    Did you bake the lighting with Bakery and then started experiencing these problems, or did you just import it into a project with non-Bakery lighting without doing anything?

    Your understanding is correct. But on top of that:

    - Multiple objects' UVs are packed together into larger atlases. When one atlas is full, a new one is allocated.

    - The min/max resolution is what affects the size of these atlases.
    Suppose you have 4 objects, each requiring 512 pixels on both sides. If your max resolution >= 1024, then all of them can fit in one 1024x1024 atlas. But if you set max resolution to 512, then 4 atlases will be allocated, each holding just a single object. If max resolution is lower than that, the lightmaps get shrinked.
    Also because currently lightmaps are always square, there are cases you may want to solve differently: consider 6 objects 512 px each - should it be 1024x1024 + 512x512 + 512x512 or 1024x1024 + 1024x1024 (not full)? If min resolution <= 512, you'll get the first option, but if it's >= 1024, it will be the second one. In general, leaving min resolution small (default value) is a good idea to prevent wasted space - but you can get more atlases in the end (and more batches).
    Reducing max resolution only makes sense if your target platform doesn't support 4096 or doesn't sample them fast enough.

    That means that your object's area*texelsPerUnit actually gives high resolution (3k), but if your max resolution was lower than that, then Bakery had no choice but to downscale it to maximum allowed size.
     
  37. TiagoTFG

    TiagoTFG

    Joined:
    Jul 3, 2018
    Posts:
    7
    Is this patch applied to the latest Asset Store version? I am getting that same behaviour with the current version.

    Thank you :)
     
  38. Yuvii

    Yuvii

    Joined:
    May 20, 2014
    Posts:
    55
    Hey, me again
    Trying to bake my exterior scene (with the method i shared you last time) and since few days i keep having the same error at 13% of baking (i guess the percentage is related to my scene).

    It's a pretty heavy scene, because it has a terrain with lot of trees/grass, but it worked before and the baking time took like ~1h40, something like that.
    I can't really say what causes this error. I thought it was because of the asset Horizon, but even with it disabled i have the same issue.
    After clicking 'OK' it says me to go to this file, but i don't know where to look to find it.


    Any solution to this problem ?
     
  39. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
     
  40. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    It's not there yet, and the patch seemed to not help in all cases. Also the bug only happened for non-directional lightmaps. However, there is a 100% way to fix it with a script.
    After you finished loading the scene, run this:

            for(int i=0; i<SceneManager.sceneCount; i++) {
    var scene = SceneManager.GetSceneAt(i);
    SceneManager.SetActiveScene(scene);
    LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
    }


    For some reason Unity loves to switch the global lightmapping mode to Directional, and you just need to switch it back, or the scene becomes all bright.

    Might be a problem. This is THE reason it takes me that long to release the upcoming update. Terrain raytracing is being completely rewritten. Current public version just uses way too much memory for them. For now try either reducing terrain heightmap resolution or simplify the scene/skylight sample count.

    jrackley:
    Does it happen on any other project as well under the same Unity version? Or only in your current project? Do you have lots of other third party assets?
    Are trees marked as Lightmapped Static or if not, are there many other non-static objects in the scene? Are they fine?
     
    Yuvii likes this.
  41. Yuvii

    Yuvii

    Joined:
    May 20, 2014
    Posts:
    55
    Doing some tests about this. I'll let you know.

    EDIT: switched the SkyLight's sample count from 32 to 16, and it worked, thanks!
     
    Last edited: Jan 18, 2019
    guycalledfrank likes this.
  42. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    55
    jrackley:
    Does it happen on any other project as well under the same Unity version? Or only in your current project? Do you have lots of other third party assets?
    Are trees marked as Lightmapped Static or if not, are there many other non-static objects in the scene? Are they fine?[/QUOTE]

    The trees are marked lightmap static (as they don't move). I do have a lot of non static objects in the scene, but they are not affected. It's only the trees turning white. And, only tree creator trees. Odd thing, is that I successfully baked the scene a few weeks ago, and the trees and everything were fine. I cleared the data, and attempted to bake again, and that is when everything went weird. Unity started autobaking, every bake I attempt fails with some error or another, or it runs out of vram memory every time. If I use the force vram option, the bake will fail within minutes, so that isn't working either. Yes, we do use a lot of extensions in our project. Most have to do with the player controller/UI/inventory.
     
  43. TiagoTFG

    TiagoTFG

    Joined:
    Jul 3, 2018
    Posts:
    7
    Thank you, this has worked :)
     
    guycalledfrank likes this.
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Sounds like there are too many factors at play:
    - Unity trees are not bakeable (they don't have lightmapping UVs), but they work fine as shadow casters and being lit by probes. They seem to work fine in general, and given you previously managed to bake them correctly, it's hard to guess what could cause the problem.
    - Autobaking is never enabled by Bakery. Must be enabled by something else. Once again, there are too many factors to consider in a large project.
    The best I can suggest is to continue testing, disabling different parts of the project, until the actual cause is found.
     
    Lars-Steenhoff likes this.
  45. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    The -7 comes from Unity's streaming texture max mipmap: I don't know why but for Unity, there's only 7 mipmap levels you can load. I tried manually forcing Unity's streaming textures to go beyond 7 mipmap levels but it crashed, so that's why I supposed -7 mipmap bias was the magic number.
    But maybe you are right and the correct number is -12
    I haven't noticed any issues with -7 but maybe it's because I'm on an Android build.
     
    guycalledfrank likes this.
  46. hyperjxz

    hyperjxz

    Joined:
    Nov 21, 2015
    Posts:
    4
    Hello, sorry to be ignorant. How can I only create one lightmap per object? Bakery produces two maps, one tga other hdr. Is there a way to have only one?


    Edit:
    Set Directional mode to None. Set Render mode to Indirect. Also in Skylight and Light components.
    To get better quality for lightmaps change import settings after bake. Change Compression to none.

    Export error. Save scene manually, try restarting Unity.

    Decomressed size error
    Error rebaking lightmap Can't decompresslodmask 602
    Delete lightmaps. Start again.

    Some CUDA error
    Error (-1) Unknonw error CUDA error :cudaDriver().CuMrmcpyDtoHAsync retuned (700) : Illegal address
    Change Texels to 30. Disable shadowmask on Skylight?

    Error 1282 memory alocation failed details function rt contextlaunch2d caught exception out of memory.
    Lower max Lightmap resolution?

    Can't repack lod uvs
    Still don't know..
     
    Last edited: Jan 19, 2019
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,666
    Apparently these are two different kinds of maps. HDR contains color information, and TGA is either direction or shadowmask depending on your settings. Engine doesn't allow them to be packed in one texture.

    In this case only HDR map is used. TGA file may still be present, but not used.

    I recommend setting GI VRAM optimization to Force OFF in advanced settings. There seems to be enough bugs associated with it (and in fact I'm fixing one right now).
     
    Mark_01 and hyperjxz like this.
  48. Mandelboxed

    Mandelboxed

    Joined:
    Apr 17, 2015
    Posts:
    50
    Hi, using Bakery and loving it but am getting some odd light spots on a couple meshes that I can't figure out how to eliminate. Sorry if this has been covered in other posts. Would love some help. Screenshot attached.



    There are other windows and other similar area lights that do not have the same problem (or at least not to the same extent).
     
  49. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    Hi MrF back on the subject of bakery shaders any chance to find a bakery 6 sided skybox in the future ?
     
  50. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Just curious, why do you need a 6 sided skybox shader instead of the cubemap one?