Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. 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. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    Cool, Thanks!
     
  2. samdpt

    samdpt

    Joined:
    Oct 1, 2018
    Posts:
    14
    Hey @guycalledfrank - For Normal Map Baking, does this only work with Directional Light? Or will it take other Static Lights into account? ty
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,263
    I'll soon be ready for bakery API :cool:

    I found the very exact procedure to sample point. I found out that the sample point map is basically just the lightmap itself, because the lightmap is an abstraction of (static) scene (all the lit point and potentially visible point). So for every lightmap point, send rays around the hemisphere, weighted by the cosine, when it intersect with geometry, report the UV of that point in the lightmap and store it into the indirection tile of that point (weight of zero mean sample the skybox using a latlong indirection). If a point is sample multiple time, we increase it's weight (or we just let the repetition in the tile work as a organic weight).

    It has the benefit that it's not random point and there is optimization that can happen because scene are made of flat triangle, which mean position and normal can be interpolated safely, as long as the data at the vertex is correctly encoded in pixel. It also mean I have options for alternative structure depending on hardware, like direct rendering in the lighting map without using the extra data map. It also have a few number of nice property like the indirect basically encoding ray between two point (ie the empty space of the scene), which mean we can inject occlusion or even dynamic bounce from dynamic objects. And ultimately, if I used an atlas of cubemap (latlong, 6faces or isocahedron map, doesn't matter) I can just ties a lightmap point to a single indirection data (instead of a tile), cubemap encoding the empty space, we can then just sample the relevant point (at the correct mipmap for gathering) using the normal of the lightmap point. We can also use a "UV lightprobe" to project dynamically the lightmap on dynamic objects using usual box projection. Up to now, teh resolution was limited by the size of the indirection map (so a 2048 with 8 size tiles mean a base lightmap of 256, which is okay for gi on part with what unity advise with enlighten with 1 texel per unit (indoor) or 0.1 (outdoor). I'm aware the system has limitation (ie suppose the whole scene is just on one lightmap + skybox), but if it is as efficient as I think in practice it's MAGIC for low end.

    That's the theory, I'll start implementation after the current task.
     
    Last edited: Oct 19, 2018
    guycalledfrank likes this.
  4. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Works with all lights and GI.
     
  5. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    383
    Thank you for the quick fix!
    But I still have some problem about broke lightmaps in v1.4 (Unity 2018.3.0b3).
    In this screenshot the same sofa.
    LEFT: The sofa is "Unpack prefab completely". Lightmaps are OK
    RIGHT: The sofa is just dragged and drop in the hierarchy. Lightmaps are broke.
    In v.1.3 lightmaps are ok in both ways (same Unity version).
    Any ideas? 2018-10-19_20h19_49.png
     
  6. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Can you try reimporting the sofa (via right click) after the patch? (and rebaking)
     
    Last edited: Oct 19, 2018
  7. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    33
    its dont work in 2018 versions
     
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Just tested it in 2018.2.2, and it works. Perhaps you are not doing something right.
     
  9. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    Alright! Got Bakery fully lock and loaded in my project.
    This is a pictie of a scene which I baked in Progressive back in the day with a i74790k CPU.
    Progressive.png
    This is the same scene baked in Bakery.
    Bakery.PNG 1. Progressive took 7-8 hours to bake that... while Bakery did it in like 55 minutes and my graphic card is not precisely top notch, having a card with double or thrice its CUDAs must be a bliss.
    2. Could only do 2 light bounces in Progressive, Bakery did 5.
    3. Bakery olved seams between lightmaps way way way better than the custom 'stitch seams' inside each object mesh renderer settings.
    4. Being able to bake only light probes is appreciated.

    Ran into some random issues though:
    Sometimes Bakery decides to act weirdly.
    greenlighting.PNG
    In my last bake it decided to place a green point light somewhere in the limits of my scene. My lights are either white or slightly yellow, don't know how that got there. Maybe it was just some random stuff since it wasn't there in my first attempt. Will try to rebake and check if it goes away.
    reflectionprobes.PNG
    Baking reflection probes sometimes give that error message. One different each time, lol. They bake though, so it's minor.
    bluelighting.PNG
    In another of my attempts I think Bakery decided to add its own skylight?? This message appeared in console:
    'Your current multi-scene setup has inconsistent Lighting settings... Consider homogenizing the following: 1/2 scenes use different skyboxes.'
    I was only baking a single scene though and its skybox was disabled (black), since it's an interior.

    I think that's all for now. Good job on the baker, it's a blast. Leaving a well deserved 5/5 in the asset store. :)
     
    Last edited: Oct 19, 2018
    guycalledfrank likes this.
  10. miniduck

    miniduck

    Joined:
    Sep 27, 2012
    Posts:
    117
    Version for Linux editor would be amazing... :)
     
  11. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    That's weird indeed. Are you using custom shaders? It's like the walls have Meta Pass outputting red/green as albedo (or emissive).

    I sometimes get that even by using the Bake button on the reflection probe without Bakery. Doesn't seem to affect anything.

    No, it never does that. Using "match skybox to light" button on the Skylight component can modify scene's skybox though.

    Thanks :)

    That's a bit hard, given I almost never used Linux in my life, and some libraries are DX11-dependent.
     
    JohnLabern likes this.
  12. Darthlatte

    Darthlatte

    Joined:
    Jan 28, 2017
    Posts:
    27
    Hi, just bought your amazing asset :) Any chance of getting the custom HDRP shader for 2018.3 beta? Thank you
     
    guycalledfrank likes this.
  13. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Thanks! It's not a priority for me right now, but I have a feeling that it shouldn't be too hard to fix. Perhaps they changed the inputs for some functions I was using.
    But in general, the situation with HDRP + custom shaders seems scary. They don't have anything like the surface shader or any other proper way except for shader graph (?), which is quite limiting. To be honest, I'm not a big fan of this pipeline due to its rigidness and complexity.
     
    Mark_01 likes this.
  14. overmats

    overmats

    Joined:
    Jun 18, 2013
    Posts:
    5
    I am on version 2018.2.13f1 HDRP 3.0.0

    I just tried the patch. It is working fine, but i had to reimport my fbx, like you mentioned @ ArchVizPRO.
     
    guycalledfrank likes this.
  15. Darthlatte

    Darthlatte

    Joined:
    Jan 28, 2017
    Posts:
    27
    Hi, thanks for the feedback, and I understand :) The errors in 2018.3.0b6 can be seen in the screenshot, if and when you have some time ;-)

    upload_2018-10-20_10-23-13.png
     
    guycalledfrank likes this.
  16. JohnLabern

    JohnLabern

    Joined:
    Nov 13, 2017
    Posts:
    75
    Yep, I'm using custom shaders but I just rebaked the scene and the green light went away... weird.
     
    guycalledfrank likes this.
  17. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    569
    Hey. Outstanding work.
    Please try to get this URL.)
    https://www.unitybaking.com

    The possibity to mix VertexBake with UVBake in a scene for really complex scenarios is a real game changer for me.

    Imagine a production car interior where most of the high detailed "bigger" meshes are automatic or manually unwrapped. There are always a lot of parts who are not as easy or nearly unimpossible to unwrap.
    VertexBake could be valuable used here.
    You could imagine a simpy subdivide of geometry in this areas of the mesh for vertex bake where it s needed to get a clean result.
    Autodesk VRED does this very good in ambient ocussion and indirect illumination vertex bake mode.

    Do you would see a benefit of it?

    Simply generate a plane and cube sitting on the plane and calc vertex ao with ind illum with subdivide enabled. Shadows are possible too. The plane who had have only 2 triangles is subdived in this areas to save a clean and smooth calculation in the vertex.

    keeponbaking.

    here you see she subdivision on the plane car stands on
    and examples on the car glas on areas it s close to the seal.
     
    Last edited: Oct 20, 2018
    guycalledfrank likes this.
  18. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    569
    ...The base mesh without subdivision should be saved too if you descide to rebake another situation. VRED does it not.

    A last missing part would be the BakeVariants.
    e.g Bake all parts who are primary visual affected when door is open and door is closed as 2 BakeVariants and give the possibility to interpolate between this 2 BakeSets during opening door animation.
     
  19. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Yeah definitely. I don't think subdivision itself should be a part of Bakery, but if you already have it, then it should work without a problem (apart from these mentioned in Vertex Lightmap notes section of the manual).

    This is actually planned. Doors and multiple on/off light situations are important, and I want them to be easy to do.
     
    keeponshading and Mark_01 like this.
  20. ovalmobile

    ovalmobile

    Joined:
    Sep 29, 2016
    Posts:
    2
    Hello, I get stuck at Adjusting sample points while rendering the lightmap. Also, I checked the path name and there aren't any special characters.
     

    Attached Files:

  21. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    I don't know any other reason for this error apart from weird characters in the path. Are you sure ftrace.exe is exactly at this path? Did you try to move Bakery's folder anywhere? Did you skip some files during the package import?
     
    ovalmobile likes this.
  22. ovalmobile

    ovalmobile

    Joined:
    Sep 29, 2016
    Posts:
    2
    Thanks, I checked the location of ftrace.exe and It wasn't where it was supposed to be :)
     
    guycalledfrank likes this.
  23. CoastKid

    CoastKid

    Joined:
    Jan 8, 2013
    Posts:
    35
    Hi Frank,
    Is it possible to get light transmitting like "Backface GI" but for real two-sided materials, with custom meta pass or somehow?

    And another suggestion from me: Do you ever think of adding Fog and Dielectric zone volumes, to make Optix bake light emitted by surrounding fog (like in "Silent Hill'' for example) or get light dimming inside of the underwater areas (get more transparent blue and dark at distance)? Could be really handy in some situations.
     
    guycalledfrank likes this.
  24. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    206
    when i add a bakery skylight and set match to scene skybox the whole scene get white and does it support speedtree ?
     

    Attached Files:

  25. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    44
    any idea why i get this error? it didnt happen before the latest update
     

    Attached Files:

  26. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Backface GI is currently the only way to emulate some sort of translucency. I'm planning to add proper translucency/scattering support, but it's a bit challenging to do it without slowing down the general case.

    Interesting idea. Doing it on a per-volume basis is tricky, but I could do something like that as a global option that could be also overridden by Lightmap Groups in the scene.
    Light absorption by fog/water seems relatively easy to implement... however, actual scattering is not.
    As I'm going to add a new custom light probe solution in the next update, I think it will also help cases like this in the future. Basically calculating direct lighting for both lightmaps and probe volumes, accounting for absorption, and then gathering data from both at GI phase should get it pretty close to ground truth in a fast way (I'm not 100% sure, but I'll give it a try when probes are ready).

    You have a white skylight. You press the button that makes scene skybox match this skylight. Scene skybox also becomes white. That's how it works. You probably wanted the other match button :)
    (I know, they have confusing names, perhaps I should name them more clearly)

    Apparently not. Will address it in the future.

    Something went wrong. 75% chance of you going out of free space on HDD (check it).
     
    lolclol likes this.
  27. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    206
    There is no other match button, if i add bakery direct light script to the directional light it show 2 button, something like lightmap matching. I am really confused btw. Sorry.
     
  28. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    206
    Using unity 2018.2.5, is this ok?
     
  29. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    That means it cannot match to your skybox. Currently it can only match to a handful of built-in skyboxes which use cubemap.
    Solution: create a reflection probe in a scene with any custom skybox -> bake -> use the resulting cubemap asset in Skylight.
    Gonna make it easier in future versions.

    Should be fine.
     
  30. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    44
    i monitored disk space while rendering and there isnt much space being used up by baking, still i get the error
     
  31. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    No idea then. Can you reproduce this error on a small scene? Or in any example scene?
     
  32. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    44
    i have another scene where it works fine, the error in this scene happens since the latest update
     
  33. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Unfortunately the only way to fix it is to locate the object/setting causing the error and report it to me. Or send me a scene causing the bug.
     
  34. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    I'm trying to understand lightmapping in Unity, however I am stuck at a UV error I keep getting with some of my meshes: "Object has no UV2" Does this mean I have to manually create the uv2 in a modeling package or is there any way to fix this in Unity?
     
  35. aeldred28

    aeldred28

    Joined:
    Dec 16, 2017
    Posts:
    30
    Generate lightmap uvs doesnt help and that is what I expected to generate in uv2.
     
    Last edited: Oct 22, 2018
  36. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    hey,

    I get some random internal error: video_shechdule_internal_error when I use high configuration to bake scene. I am using GTX1080.
     
  37. ViewportAU

    ViewportAU

    Joined:
    Mar 26, 2014
    Posts:
    25
    We are still getting the UVW overlap issue on externally unwrapped meshes, even after applying PATCH 1.41.
    Meshes with the issue are baking OK on Enlighten / Progressive and previews Bakery 1.3. I wonder if I have applied the hotfix correctly. I just clicked on the Patch link, download it, and update what was new from the package on my existing project with Bakery 1.4
     
    Last edited: Oct 22, 2018
    ArchVizPRO likes this.
  38. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Hey, Also when I baking some other room of my game. It seems some material emission isn't baking right. You can see from the following screen shot. Both light using material emission but the left one is not baking.

    I am using Emissive Material.


    upload_2018-10-22_14-49-56.png
     
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    There is a "generate lightmapping UVs" checkbox on the asset.

    I wonder why the first object is called "precombine"... are you using any mesh combiner script? If so, it could generate a new independent mesh, that is no longer linked to the original model and its UVs.

    Does it happen when the bake is almost finished? I had a similar report, caused by using the denoiser on a specific scene on a specific version of Win10. Seems to be fixed by the newer OptiX library. In any case, please try disabling Denoise in advanced settings. If it helps, I'll send you (and everyone) the patch.

    Any chance you can send me a model with this bug?
    Maybe you have any script compilation errors in the project preventing Unity from also compiling 1.41 scripts?

    That's very odd. As with other problems, is it possible to reproduce on a small scene and send it to me for debug as unitypackage?
     
  40. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Yey, It seems it will not break if I disable Denoise.

    I am already make a unitypackage. How should I send it to you, I cannot find your email at store page anymore.
     
    guycalledfrank likes this.
  41. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    41
    Find your email at old asset store page. Already send a small scene with this bug. Thanks.
     
    guycalledfrank likes this.
  42. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    Hi dear Frank, it's me again! Happy using V1.4, amazing!
    I got two questoin today.
    1. Can I install bakery to a destination folder instead of Asset? Because as I notice bakery paths are fixed in some files.
    2. And which cs file should I look to make a portable Lighting data asset? I may want to switch lightmap in some cases.
     
    guycalledfrank likes this.
  43. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Currently you can't and the paths relative to Assets are hardcoded. It's a bit tricky to avoid it, but I'll try to improve it the future.

    Can you elaborate? What should portable mean? Switchable lightmaps are planned - currently you can just manually script it by loading the assets and putting them into the LightmapSettings.lightmaps array.
     
    liudian208 likes this.
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Thanks - I think I figured it out.
    You have "cast shadows" disabled on these lamps. That makes them basically invisible for the lightmapper (so they only receive lighting, but don't affect it). However a consequence of this is that they also don't emit light. Enabling "cast shadows" on mesh renderers fixes it.

    This is not exactly logical on a first glance, but if you think about - emissive surface is a surface. We either allow all rays to pass through it, or let them hit it, resulting in shadows and emission visibility. Picking up emission from the surface and then continuing the ray is perhaps closer to what people would expect, but it's not easy to pull that off without slowing down the GI phase in general, and it hardly makes any physical sense.
     
  45. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    Thanks!

    "portable" means are two things, one is that I want to use lightmap without including bakery cs scripts( like enlighten's result), the second is that there is a case that I need to use the baked maps on another .unity scene file (with very few differences with the scene I baked). I wonder why I can't just copy baked lightmap data asset and maps to the project and load the lightmap data asset.
     
    guycalledfrank and ArchVizPRO like this.
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Ah yeah. Had this problem as well. I'm going to implement a script like that, but currently it seems like you need to include almost all cs scripts, because of cross-dependencies (exe/dll/ptx are not needed though).

    You can probably copy the non-lightmapped stuff into the lightmapped scene and resave it (?) instead of trying the other way around.
     
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Due to popular demand, I've just added Bakery-specific checker visualization.
    As you may have realized, Unity's own "baked lightmap" visualization does not show correct texel sizes for Bakery, as it is based on Unity's atlas packer / lighting settings.

    upload_2018-10-22_21-57-25.png

    upload_2018-10-22_21-57-37.png

    The refresh button is due to complexity and a huge amount of affecting parameters Bakery atlas packer has. It was either this button, or runtime hiccups each time you change any affecting value (the button still takes around 1 second or less on most scenes I have).
     
    lolclol, lightwaterjohn, osss and 4 others like this.
  48. zornor90

    zornor90

    Joined:
    Sep 16, 2015
    Posts:
    179
    Wow I am impressed, after three years you've done what unity can't - give me the ability to have lightmapped prefabs! Thank you so much



    I am getting an error when streaming the prefab containing the lightmap into the scene:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. ftLightmaps.RefreshScene (Scene scene, .ftLightmapsStorage storage, Boolean updateNonBaked) (at Assets/Bakery/ftLightmaps.cs:567)
    3. ftLightmapsStorage.Awake () (at Assets/Bakery/ftLightmapsStorage.cs:222)
    4. UnityEngine.Object:Instantiate(GameObject, Transform, Boolean)
    5. CB.Streaming.StreamedRoom:OnPrecombineLoaded(GameObject) (at Assets/Project/Scripts/Streaming/StreamedRoom.cs:117)
    6. CB.Streaming.<LoadAsync>c__AnonStorey0:<>m__0(GameObject) (at Assets/Project/Scripts/Streaming/AssetReference.cs:90)
    7. CB.Streaming.<_Load>c__AnonStorey2:<>m__0(GameObject) (at Assets/Project/Scripts/Streaming/StreamingAssetsManager.cs:143)
    8. CB.Streaming.<_LoadFromBundle>c__Iterator0`1:MoveNext() (at Assets/Project/Scripts/Streaming/StreamedBundle.cs:74)
    9. MEC.Timing:Update() (at Assets/Plugins/Trinary Software/Timing.cs:401)
    I was also wondering if it would be possible to somehow let me handle calling the fLightmaps onenable via script? Because of how I stream assets I am trying to avoid as many Awake(), OnEnable(), and Start() calls as possible on streamed prefabs

    Also, in terms of how to set up a prefab lightmapper, what you might consider is a window that can take a reference to an already made prefab - then you can just update that prefab with PrefabUtility versus having to auto generate the prefab. So the user would be responsible for making the prefab, then drag a reference into the window and click Bake() which would do all the automation, put fTraceLightmaps into the prefab and save it, clear the scene cache, etc

    I actually started doing that myself, but was unable to figure out how to hook into the Bakery API
     
    Last edited: Oct 23, 2018
    lolclol and guycalledfrank like this.
  49. ViewportAU

    ViewportAU

    Joined:
    Mar 26, 2014
    Posts:
    25
    Can I please have an early access to this checker? It would be awesome to use Bakery for a project due this Friday, and this checker is the last bit I am missing.
     
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,313
    Lightmapped prefabs weren't intended to work, and it's just a coincidence they do. Things like that shouldn't happen if it would be implemented properly.
    In this case, the error is caused by the script trying to apply shadowmask settings to a light. Perhaps you deleted that light from the prefab, and the script can't find it?

    Well nothing prevents you from renaming OnEnable to any other function name and then calling it manually.

    Sounds like a good idea. So it's like you drag the prefab into the main window, and then the Bake button will only bake this prefab?

    For some reason I can't send you a private message - maybe try messaging me, and I'll reply.
     
    Last edited: Oct 23, 2018
unityunity