Search Unity

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

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

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

  1. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Im also curious, since sometimes i have to render huge scenes and for now i just have 8gb vram, if we get to that limit it will crash no? An out of core solution (so we can use the ram of the pc - i have 64gb) if we reach the limitation of our graphic card is something that you would consider in a future? Is something really hard and time consuming to implement? I have no idea... i know it would be slower but maybe it would be better to take longer in those cases than not to bake at all :)
     
  2. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    GI is the most demanding part of the process, and GI VRAM optimization option should help not going out of mem there.
    I saw some people getting errors with the optimization enabled though, and it would be very helpful if someone could share some test scene where the problem is reproducible.

    Out of core is hardly possible to do with GPU lightmapping sadly, since accessing main memory from the GPU is much, much slower than VRAM. Seems like OptiX library originally had some out-of-core implementation, but they removed it: https://devtalk.nvidia.com/default/topic/1028598/optix/out-of-core-features-in-optix/
    I don't think it's a great idea in general... a better idea would be to split the scene into relatively contained chunks during export, possibly with auto-generated LODs, caclulate their inter-visibility and bake. That's also exactly what GI VRAM optimization is doing - but it only does it for lighting data, not geometry.
     
    Archviz3d likes this.
  3. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Aaaand 1.4 is out now!
     
    Mark_01, tntfoz, Gametyme and 7 others like this.
  4. NERVAGON

    NERVAGON

    Joined:
    Oct 27, 2009
    Posts:
    73
    Would it be possible to do a hybrid preview render similar to the method used in RTX raytrace demos? Basically inject the lighting from your path tracer into a raster camera frame?
     
  5. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    That's kinda hard. RTX demos had a complete control over render pipeline. But here we have standard + HDRP + LWRP + all kinds of custom user shaders and effects, so correctly mixing path traced lighting with that is close to impossible. Can be doable for JUST standard pipeline + surface shaders, but not sure how useful is that.
     
    NERVAGON and YouDesign like this.
  6. zornor90

    zornor90

    Joined:
    Sep 16, 2015
    Posts:
    178
    Hey, so this asset looks really promising

    My game generates the map at runtime from a collection of room prefabs. These rooms each have their own collection of lights, models, etc

    I create a single scene (well, several, but just one Game scene for a map) that the rooms are loaded into. The rooms are placed at random so we have not been able to bake via unity's lightmapping, nothing is static, etc.

    Would this asset allow us to bake lightmaps and GI to each prefab, and then at runtime load and position (place and rotate 0, 90, 180, or 270 degrees) each prefab inside the scene so that lightmaps work for all rooms? I saw something about it in the intro, but wanted to make sure before checking this out that it doesn't require one scene per prefab

    I saw that you can't bake a multi prefab scene, that's fine I could easily script automation to bake each prefab in a scene during our build step - just want to know if you can load multiple prefabs with lightmapping into the same scene
     
    Last edited: Oct 18, 2018
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Yes, it's doable, and it's in the FAQ. In fact... I've just recorded a video of this in action:




    The method is sort of hacky, because this feature was never intended to exist, but it still works. I'm still not sure how to properly design it, as there is no event in Unity I'm aware of that would signal when you create a prefab out of something.
     
    Last edited: Oct 18, 2018
  8. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Hey I got some error about mesh UV like this:
    Mesh Big_Light on object Big_light has incorrect UVs (True, 0.5896554, 1.427908)
    [Bakery warning] 257 pixels overlap: Assets/Res/Models/Env/Common/Hall/Railings.FBX

    What is those error is about? especially the error one.
     
  9. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Apparently it's because you mesh has incorrect UVs.
    How were they generated?

    This error won't prevent Bakery from rendering the lightmap, but you'll get artifacts on the object, if the UVs are overlapping.
     
  10. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    Hey Mr F! I'm experimenting with your lightmapper hoping it will replace Progressive in a future in my project. I'm using a triplanar shader in some parts of my scenes and it seems they get bugged when using Bakery. (check attached pic, left: progressive, right: Bakery).

    Reading previous post I think this is related to a lack of meta pass in the shader? (I'm a shader noob) Can you confirm it?
    CPU-GPU-Lightmap.png

    Edit: Actually I used the material in simple planes and the shader seems to work... I'm experimenting to see what's going on. Something related to prefabs? o_O
    SimpleLightmap.PNG
     
    Last edited: Oct 18, 2018
    guycalledfrank likes this.
  11. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi Frank, i recently deleted Bakery from one project and i got a warning which tells that there is a gameobject with missing script left somewhere. I couldn't find one. I only can guess that it is some hidden file left in the scene.

    The target game object ( or script ) is !ftraceLightmaps. I double clicked on the warning and the object got selected and then i simply deleted it !

    Any idea why and how it left !?
     
  12. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    It's hard to say at the moment... needs more investigation. The broken pic is looking like there is something weird with UVs. Can you check the same model with a standard shader?

    It can be only a problem for getting correct GI and emission, but not what you are seeing.
    Also both Progressive and Bakery use the same meta pass, so if one works, then another should too.

    Ah yes it's hidden and called !ftraceLightmaps. You can delete it via script. "Clear baked data" button also deletes it as well, and I recommend first closing the Bakery tab completely before using it (otherwise the tab may still save some render settings).
     
  13. rotsin

    rotsin

    Joined:
    Feb 22, 2013
    Posts:
    8
    @guycalledfrank
    Hey, great work on the asset! I especially found the prefab light baking very interesting. I had one question related to that technique. Would it be possible to have a transparent plane at the base of those walls that would contain an alpha mapped shape of the shadow that is being cast on the ground? I think it's called a matte-shadow shader, but the question here is more if or how it could be achieved using your great plugin?

    EDIT:
    Also, if the above would be possible, could the texture on that plane be attachet to a camera mapper in order to place it as a decal on the surface below?
     
    Last edited: Oct 18, 2018
    guycalledfrank likes this.
  14. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    35
    we are working on a game that most of it is procedural, (instantiating prefabs)
    but somehow the lighting light probes and everything regarding this is missing when we do this.

    is there a workflow for this ?

    the game is for android.
    Bakery manages the lighting pretty awesome ... but i need to know if there is a way to reduce the overall size of the project?
    like is it writing all the data into the lightmap file (normal maps specular etc) into one file ... is that possible to use the bakery generated file instead of all the materials and textures we have right now to reduce the size and increase the performance ?
     
  15. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    I checked with a standard shader and the result was the same, but you are right, the UVs were the problem... which is weird considering I spent some time in Blender optimizing them and as you can see in that previous Progressive picture they weren't a problem there.
    BakeryFixed.PNG
    I activated Generate Lightmap UVs in every mesh and it got fixed, I guess I'll have to let Unity generate all lightmaps when I include Bakery in my projects workflow instead of creating them myself (d'oh).
    Will post here some after/before pictures when I update all my scenes to your lightmapper. :)
     
    guycalledfrank likes this.
  16. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    36
    Actualy while Bakery window active you may create FileSystemWatcher and filtering file creation events by project folder and extension *.prefab*.
     
  17. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Well that's a very special case. Doesn't mean it's impossible though. You can bake the shadow on a regular white plane, then all you need is basically ANY unlit shader with lightmap support and multiply blend (Blend DstColor Zero).

    That's definitely beyond the scope of Bakery, but you can make a shader like that :)

    Bakery just fills the data for regular Unity probe assets. Unity's probes are a pain in the ass when it comes to combining multiple scenes. I'm working on a new independent probe system, but for now, maybe this link will help?
    https://assetstore.unity.com/packages/templates/tutorials/additive-loading-lighting-examples-129922

    Hmm interesting. Perhaps there is something wrong with the overlap detection algorithm. Any chance if you can send me this (or simiar) model, so I can debug?

    Hmmm... that is possible. Interesting. I don't know how stable this solution would be though... prefab can be created externally, by a version control system, for example, and then it shouldn't be linked to the active baked scene.
     
  18. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
  19. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    I did not. Ask zagreekie ;)
     
    lolclol likes this.
  20. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    finally!
    V1.4 equals to Mission Accomplished.
    This is now fully production ready for all project types, whatever comes now is a bonus.
    Thank you very much for your commitment.
     
    Mark_01, lolclol, w00dn and 1 other person like this.
  21. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    Sent it your way via PM, first package I export, hopefully I did it right...
     
    guycalledfrank likes this.
  22. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
    Hi what shaders are you using and lighting method? Can you pls share the process? Thanks.
     
  23. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    36
    Apart from FileSystemWatcher you can use direct unity way:

    Code (CSharp):
    1.  [MenuItem("Window/SomeWindow")]
    2.     public static void ShowWindow()
    3.     {
    4.         GetWindow<SomeWindow>("SomeWindow");
    5.         PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdate;
    6.     }
    7.  
    8.     static void OnPrefabInstanceUpdate(GameObject instance)
    9.     {
    10.         UnityEngine.Debug.Log("Prefab created or moded :" + instance.name);
    11.  
    12.     }
    OnPrefabInstanceUpdate 100% will fire when you drag object from scene to project window to create prefab

    And in case to triple check you always can get all objects in scene (SceneManager.GetActiveScene().GetRootGameObjects() and iterate throuse all children) and check them by PrefabUtility.GetPrefabType
     
    Last edited: Oct 18, 2018
    guycalledfrank likes this.
  24. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
    @guycalledfrank i have gtx 750ti 2GB GDDR5, will bakery work with 750ti?
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Yes, it should. 2 GB can be a bit limiting though, but if you don't have HUGE scenes, then it's still should be usable.
     
  26. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    83
    Hey @guycalledfrank, is there anything in the works for supporting those with AMD graphics cards? Also, is there anything fundamentally stopping Bakery from being converted into a run time light map baking solution? I'm interested in making an in-game level editor with an option for light baking and Bakery looks like it could potentially be ideal for handling this. Thanks!
     
  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Unfortunately no.

    Unfortunately everything. Like players having AMD graphics cards as well.
    The requirements for runtime baking are wildly different.
     
  28. Yuki-Taiyo

    Yuki-Taiyo

    Joined:
    Jun 7, 2016
    Posts:
    72
    OOF ! :confused:

    You increased the price for the update. I should have bought Bakery earlier...
     
    Last edited: Oct 19, 2018
  29. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    I use unity generat UV......So if I use Maya to bake UV. I need to bake to UV2, is that right?
     
  30. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
  31. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    If I paid 300$ I would still be happy. All the time this thing saves and the quality it outputs is well worth it, the dev had the deference of not focusing only on pro devs and pricing it super low, the 55 atm is peanuts for what you get.

    What otherwise, wait 3 days for Enlighten to output something you realize needs tweaking? XD.
     
    Mark_01 and Archviz3d like this.
  32. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    230
    Is Bakery output closer to Enlighten or Progressive quality? I've been playing with that kitchen scene that a Unity employee linked earlier in the thread as a bit of a stress test and while it looks great using auto-unwrap with Enlighten it's an absolute dogs breakfast using progressive no matter what settings I try. If Bakery can handle it well that's very impressive. (I've tried the progressive GPU and it just immediately crashed. :D )

    Edit: I know there were some Bakery screenshots of that scene on the previous page but since it used vertex lighting for some elements it isn't a fair comparison.
     
  33. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412
    You can say that again :D Even Unity knows that. One of their lightmapping Unite talks were called "Bake it 'til you make it"
     
  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Yes :)

    There are screenshots of it in Bakery just a few posts after the link.

    Only for snacks and garlic I think. And that's why they got some seams.
    I don't think I can answer your question - I didn't try to match the quality of neither Enlighten nor Progressive, but I tried hard to achieve a clean output and physical correctness (using Mitsuba as reference).
     
    Adam-Bailey likes this.
  35. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Hey,

    I figure out how to make uv right and the quality of baking is amazing.

    I always get this error msg at the end of baking, it seems not affect the result.

    The loaded level has a different lightmaps mode than the current one. Current: Non-Directional. Loaded: Directional. Will use: Non-Directional.
    ArgumentException: The scene is not loaded.
     
    guycalledfrank likes this.
  36. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Thanks for all your details on your explanations and the quickness of it :)
     
  37. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Awesome!!! Thanks for the video!! It really helps visualizing everything quickly!!
     
    guycalledfrank likes this.
  38. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Its still cheap for all it can do!!! And all the effort put on it...and the way he constantly replies to us here...giving us the insight of things and helping with our doubts...
     
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    That's an odd Unity error when multiple scenes with different directional modes are loaded at the same time - it doesn't seem affect anything, but I'll see if I can get rid of it.
     
  40. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Thanks for your reply

     
    lolclol and guycalledfrank like this.
  41. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
    wow great, i am so happy.
     
  42. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    201
    unreal engine like lighting inside unity, great work mate.
     
  43. overmats

    overmats

    Joined:
    Jun 18, 2013
    Posts:
    5
    Hi guycalledfrank,

    first thank you for this great piece of software. Now i have the lightmap solution i was missing in unity all the time.
    I have some problems with the new 1.4 Version. I did not change anything, only installed version 1.4

    Now after baking, some meshes have overlapped uvs. Lightmap uvs are in uv2 and done in blender. No automatic unity generation. With generate lightmap uvs I works fine, but as you mentioned in your manual it is better to prepare the lightmap uvs by hand, like I did and they worked fine with version 1.3.

    I noticed that the meshes are treated like they are one combined mesh, but they are separated and only imported as one fbx file. When i move the pieces out of the parent in the hierarchy it bakes fine. But then I lose the prefab connection. Any glue what has changed? Attached a screenshot of one of the meshes. The lightmap of the part below is used for all 2 meshes.

    I also tried out the new hdrp shaders, but after unzipping I get an error message and the shaders appear as not compiled:

    Shader error in 'HDRenderPipeline/Bakery Lit': 'GetPositionInput': no matching 5 parameter function at Assets/Bakery/shader/BakeryHDRPShader/BakeryHDRP_GBuffer.hlsl(39) (on d3d11)

    Compiling Vertex program with LIGHTMAP_ON DIRLIGHTMAP_COMBINED _NORMALMAP _MASKMAP _MATERIAL_FEATURE_CLEAR_COAT _NORMALMAP_TANGENT_SPACE
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

    Shader error in 'HDRenderPipeline/Bakery Lit': invalid subscript 'positionWS' at Assets/Bakery/shader/BakeryHDRPShader/BakeryHDRP_GBuffer.hlsl(39) (on d3d11)

    Hope that helps, and you find a solution.

    Thanks in advance
     

    Attached Files:

    guycalledfrank likes this.
  44. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    @overmats I had this problem as well, I solved it for now by letting Unity generate the lightmaps UVs but as you said it may better if they are done manually. I think Mr F was addressing this issue.

    But since Bakery seems to have a cool auto UV padding adjustment, I wonder if I should just do manually UV1s and let Unity and Bakery do their work with lightmaps UV, since it calculates the most optimal padding...?
     
    guycalledfrank likes this.
  45. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Yeah, that seems like a bug, similar to what JohnLabern experienced, related to incorrect overlap detection in prefabs.
    Gonna release a hotfix soon.

    What version of Unity are you on? I tested in on 2018.2.2, but it's possible the HDRP shaders changed since then.
     
  46. vortexilation

    vortexilation

    Joined:
    Sep 25, 2009
    Posts:
    290
    @guycalledfrank

    My Unity 2018.3.0b6 is turning whitish after rendering the lightmap.



    Another question is my rendered lightmap is not anti-aliased, i have already increasing my texel per unity into "30" but still getting jaggies line.
     
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Seems like some beta bug? 2018.2 is still the latest stable version I think.

    To prevent jagged lines you should either make the shadows blurrier (increase the shadow spread on the light source) or/and enable bicubic filtering (Bakery->Shader tweaks; may need Unity being launched as administrator).
     
    lolclol and vortexilation like this.
  48. vortexilation

    vortexilation

    Joined:
    Sep 25, 2009
    Posts:
    290
    Just reported the bug! Case 1092485, thanks now the anti aliasing are better.
     
  49. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    374
    Same problem here.
    All geometry that doesn't use the "Generate Lightmap" option, have broken lightmaps.
    In version 1.3 everything worked fine, but in 1.4 I can't use manually generated UV anymore.
    Is possible to get a fix without waiting for a new version?
    Thank you!
     
    guycalledfrank likes this.
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,309
    Alright, I think I figured it out. Please try the attached patch.
     

    Attached Files:

    Mark_01, TooManySugar and JohnLabern like this.
unityunity