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. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
  2. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Fast propossal for an open discussion.
    Probably there is an better, faster way or it is not possible due to bakery architecture or planed prefab workflow.
    I am also not into multi scene.

    However, i miss this per scene:

    on the right.
    Group parameters are extended and you can add objects or prefabs.

    Bakery Jobs Window can render selected groups. Batch would be ok.

    BakeryJobs.jpg
     
    guycalledfrank likes this.
  3. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Hey, it was indeed the disk being out of space! Thanks :)
     
    guycalledfrank likes this.
  4. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    Yes, still crash. I'll try send you a copy today.
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Just been trying to use this asset. A quick question. Will this asset can take adventage of RTX series video card's raytracing feature in anyway? Anyone?
     
  6. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    I actually plan to try implementing client/server bakes pretty soon, because I have 2 PCs and would like to use one for bakes while working on another.
    However:
    - Distributing the work to > 2 PCs is hard to test. Also some tasks can't be run in parallel, like GI, which is sequential. Direct lighting, denoising and everything else can be parallelized.
    - While it's a good idea in a LAN, it's probably not that great if your other machine is somewhere far away on the internet. You'll have to transfer gigabytes back and forth, and in the end it'll be probably slower than just baking on your own PC.
     
    frankadimcosta likes this.
  7. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    39
    +1
     
    atomicjoe likes this.
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Many global parameters can be in fact added to Lightmap Groups, but not all. E.g. GI VRAM optimization is a global switch. Which currently global options would benefit most from being per-group for you?

    Why not add the component ON these objects (the way it works now)? Navigating Unity editor hierarchy is easier than a barebones 1000 items long list.

    This one makes sense I guess.

    Received the file - will check now!

    Bakery is based on OptiX, so you can refer to this thread: https://devtalk.nvidia.com/default/topic/1039276/does-optix-5-1-support-the-turing-architecture-/
    In general: AFAIK, denoiser should be able to use Tensor cores, but RT cores are not yet utilized.

    What do you guys use baked skinmeshes for? :D
     
  9. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    39
    This is really important, especially if there is partial colored transparency from the windows.
    Maybe it is too much to ask, but what about refraction and caustics :p ?
     
    guycalledfrank likes this.
  10. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Caustics are nice, but fairly hard to implement without making the bake super-slow.
    I can do a relatively fast version limited to direct lighting from the sun/points, but a fully unbiased solution with even indirect lighting being able to produce caustics is not easy. I wonder if it'll be enough for most cases.
     
    Lars-Steenhoff likes this.
  11. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Can we please have an option so that we can also click to choose the location for the generated lightmaps? It may also be a good idea to somehow try and keep that path as per scene as well... Or have an option to place them just like how Unity does... relatively to the scene path.
     
    frankadimcosta likes this.
  12. liudian208

    liudian208

    Joined:
    Aug 30, 2018
    Posts:
    59
    I have a RTX2080TI, the speed is faster than 1080TI , saving about 50% time, FYI.

    It has already, as long as you chose upload_2019-1-25_16-40-59.png
     
    Last edited: Jan 25, 2019
    guycalledfrank likes this.
  13. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Here a couple of reasons ( not that there is no any other way around this but ... :) )

    imagine that you have some rigid models types but with blend shapes, you touch the blend shapes and want to use the model as rigid one ( here as soon as you change topology it will not probably baked that good but still works ). Another thing is that you might have a skinned character and you want to used it as a statue - you change its pose and then bake it... I have done this !

    Well as this is actually possible it is more in the circle of joke, but i actually used that workflow !

    A way around these two cases is to write a simple script which makes a snapshot of the skinned mesh into a MeshRenderer and then you can bake it which is probably the more correct way !

    So it is up to you to decide if you add support for SkinnedMeshRenderer !

    Cheers !
     
    atomicjoe and guycalledfrank like this.
  14. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    You can... type the location (output path in advanced settings). Why not click? Because folder must be inside Assets. Standard Windows directory dialog would allow any folder anywhere. Maybe I should go with the dialog but then show an error if the folder is outside of Assets?

    Interesting! Well 2080TI IS probably faster than 1080TI, even when not taking RT cores into account.

    Choosing Advanced is enough.
     
  15. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    If uses GDDR6 and has 700+ more CUDA cores - this is probably a good boost in speed.
    But when you utilise the RT cores it should be tracing multiple times faster, then you will get a fast baking :D right !
     
    guycalledfrank likes this.
  16. Fishing_Cactus

    Fishing_Cactus

    Joined:
    Nov 8, 2014
    Posts:
    45
    Hi, We're seeing several warnings emitted from Bakery on 2018.3.
    Could you please fix those in the next update? ;)

    Thanks for the awesome work!
     
    guycalledfrank likes this.
  17. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Simple: on low end hardware like mobile and Nintendo Switch, screen space ambient occlusion is too expensive to use (it's fill rate related. Any full screen image effect is a big hit in performance. Even with rendering order you have to be VERY careful or the framerate will tank badly!)
    So the only viable solution is to bake some ambient occlusion on the skinned meshes of the characters.
    You place them in an X position and bake AO directly on the albedo texture maps (or on a separated channel if you feel like using Unity's standard shader)
    It works marvelously well.
     
    guycalledfrank likes this.
  18. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I recently sought some benchmarks of OptiX comparing GTX1080 and RTX2080. The render times between this two is reduced in HALF.
    The benefits of using an RTX card is much bigger for rendering than for gaming!
     
    guycalledfrank likes this.
  19. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Or let us drag the folder into some slot and the tool can get the path relatively to the asset folder. I know this will work , because I do this all the time in my own editor script.
     
    guycalledfrank and atomicjoe like this.
  20. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    YES, PLEASE.
     
  21. elamhut

    elamhut

    Joined:
    Sep 13, 2013
    Posts:
    45
    Hello I'm getting a Bakery Crash when trying to bake my scene, I have absolutely no Idea why this is happen. Can anyone give me a hand?



    Edit: I kinda figured out what was going on, I had created area lights (unity) and I put the Bakery Light Mesh Script (with no mesh whatsoever) but somehow it created permanent Empty Mesh Renderers in those prefabs, I don't know how. I know that Bakery Area needs a mesh, but I thought just adding the Bakery Light Mesh script to a Regular Area Light and baking it on Bakery would be fine (it was actually fine during some tests, it created a light mesh, rendered, then deleted it after the bake). I don't know why those prefabs stayed with an empty Mesh Filter/Renderer tho...

    But now I'm having an even more complex Error, don't know how to fix.

     
    Last edited: Jan 26, 2019
  22. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    It should be fine, but it's probably not in 1.45. Sounds like a bug I fixed in the upcoming release though :)
    I should be able to finally release it in 2-3 days.

    This one shouldn't break the bake. Is it doing anything after it?
     
  23. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    There are some warnings on almost all versions, mainly Unity complaining about some APIs being obsolete. This is inevitable when Bakery is made to work on many different versions. As long as these APIs work I don't think it's wise to introduce different code paths for different Unity versions, as it will potentially lead to more subtle bugs.
     
    Mark_01 likes this.
  24. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    Mr.F did I read someplace about a possible light probe update if so could you introduce any details yet? how is the bakery road map coming also did you get progress on your game with all this other activity
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    I was planning to release it in 1.5, but it's delayed now due to the insane amount of optimization/bugfixing work.

    Switching back and forth. Last few weeks it was Bakery only.
     
    Last edited: Jan 26, 2019
    Mark_01 likes this.
  26. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    In a saturated gaming market, maybe that's what we should all do: selling shovels in the gold rush...
     
    b4th, guycalledfrank and Mark_01 like this.
  27. elamhut

    elamhut

    Joined:
    Sep 13, 2013
    Posts:
    45
    Hey guy, thanks a lot for the help!

    Turns out I could bake the area light by just adding the Light Mesh script to an Area Light it so it's working fine on 1.45 :)

    The second error it took me 2 or 3 unity restarts and I had a successful bake! Took a long time since I wanted extreme resolution. But I need some help figuring out what happened to the end result, could you help me?

    Unity_2019-01-26_19-50-23.png

    My problem is the color gradient, how the light is going from light to dark... It seems like the effect you get when you have less colors in your palette, do you know why this would be happening? I was trying to achieve a very smooth gradient as end result :/

    Cheers!
     
  28. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    This is likely due to texture compression. You can try disabling it or changing the type of compression on the asset (select actual lightmap textures in the asset inspector -> change compression settings -> hit apply; no need to rebake).
    It may also happen with non-HDR rendering and some post effect brightening the image.
     
  29. jekifow

    jekifow

    Joined:
    Jan 27, 2019
    Posts:
    3
    Hey Frank, I am having a bug where this happens, to fix I have to hit update skybox probe but it keeps on happening, any ideas why? Really makes Bakery unusable for us...also it doesnt just happen on trees but also on static meshes and even post process effects like godrays.


     
    Last edited: Jan 27, 2019
  30. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    At step 2 (rendering) 15% a memory allocation error occurred. I pressed "cancel" and rendering stopped.
    An alert has showed ""trace error: unkwnow error. See .ftracelog.err for details (1)"
    But GPUI don't purged frender directory.
    PS: where is the .err file ?
     
    Last edited: Jan 27, 2019
  31. elamhut

    elamhut

    Joined:
    Sep 13, 2013
    Posts:
    45
    Hum... I tried removing the compression from all the lightmaps and the textures proper, didn't fix it... Strange is that when I see the lightmap on Baked Lightmap view the gradients are completely fine... I'll do some more tests with different Directional Modes, see if I get better results. It could be caused by our texture and not bakery.

    Also I'm getting the following error when trying to Checker Preview 2 loaded scenes:
    2019-01-27_11-47-27.gif
    Unity_2019-01-27_11-48-39.png

    This only happens in some scenes, I don't know what's causing it. Then when I try to bake the lightmaps it gets stuck on 55% and spits out a Nullref, than I'm forced to restart unity and retake the bake.
     
  32. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    It's fixed already. Will send you a patch.

    Assets/Editor/x64/Bakery/.ftracelog.txt

    ??

    Shading/postprocessing/various rendering stuff can cause similar banding.

    The error doesn't tell much unfortunately. You should try locating exact objects causing it.
     
  33. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    "Used host memory: 0mb, available GPU memory: 1602mb
    Launch 8x8 tiles...
    Tile 0x0...
    Streaming...0
    npHD
    Launching...
    Error (1282): Memory allocation failed (Details: Function "_rtContextLaunch2D" caught exception: Out of memory)"



    This one ! Why memory error ? I have 16 GB RAM and a 2GB+8GB shared video card (GTX 950)
     

    Attached Files:

  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Log says you have more than 200 lightmaps. This is... not normal. I suggest reducing Texels Per Unit.
    Even if it would fit in your memory, it won't fit in player's memory.

    What exactly is "2+8"? AFAIK GTX 950 is 2GB.
     
    frankadimcosta likes this.
  35. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    I set 2 texel per unit. Map is large

    But i have another scene with 629 lightmaps (512x512 pixels) and 419,4 MB in memory (computed using enlighten lightmapper).
    Scene runs flawless in my PC in editor and in standalone windows build..
     
    Last edited: Jan 27, 2019
  36. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    How large is large?
    It might be a good idea to set low (maybe even lower) global resolution, but then increase Scale In Lightmap on important objects.
     
  37. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    8425.698 x 3178.153 x 11736.5
    It's a space scene: an orbital space station.

    Unity enlighteen is running good. Slowly but no problems.

    PS: I have a city scene large 50.000x50.000 x 12.000, with 629 lightmaps (512x512 pixels) and 419,4 MB in memory (computed using enlighten lightmapper).
    Unity lightmapper works well and I can run scene in editor and in standalone build.

    I don't need high resolution. The player is an air fighter.
    You can take a look to this video.
    https://www.afc82.com/XXVCenturyRedBaron/Pre_GamePlayMission03_Vers01.mp4
     
    Last edited: Jan 27, 2019
  38. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Feels like Enlighten was simply skipping some objects which Bakery doesn't, because (with identical Texels Per Unit value) I don't see how it could work.

    Also: you can enable GI VRAM optimization in advanced settings in see if it helps.
     
  39. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    Enlighten is now running. I think it needs a day. Tomorrow, when completed, I'll post the results.
    PS: I'm using the "default-very lowresolution" profile for "lighmap parameters"
     
  40. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    If you're baking precomputed realtime GI, it seems like it's using 0.125 texels per unit with this profile.
     
  41. elamhut

    elamhut

    Joined:
    Sep 13, 2013
    Posts:
    45
    Hey Guy, thanks a lot for helping me on a Sunday man, you're amazing :)

    So, I did some tests, trying to delete each and every single object in the scene I was assuming I was getting the error from, even with the entire scene empty I was still getting errors!

    So I did some more tests, I tried just checkering each scene separately and they worked, then I tried inverting orders, I tried opening first the gameplay scene then the art scene and it worked! For some reason Bakery is giving me trouble when I put the Art Scene before the Gameplay Scene but not vice-versa, check the gif out:

    2019-01-27_15-29-22.gif
     
    guycalledfrank likes this.
  42. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    Mixed lightning / Shadowmask.
     
  43. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    Hey @guycalledfrank - could you give a bit of detail about the new light probe system please? I.e. what are the benefits versus standard light probes? I'm getting towards the 'baking lots of scenes' stage of my current project and will be using light probes, so wondering whether to hold on and wait...?

    edit: additonal question: if I want to pack all scene geometry into one lightmap I think I add a Lightmap Group to a parent gameobject set to 'pack atlas' - cool. However when I do this I seem to lose the ability to adjust overall lightmap resolution ('texels per unit') in the lightmapper settings. Is that right? Am I missing something? Do I need to adjust the scale in lightmap for each mesh renderer individually?
     
    Last edited: Jan 28, 2019
  44. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    That's SO 80s... :D
     
  45. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am wondering if mesh emission baking takes account of emmisive texture channel? Or does the whole mesh itself becomes a light source no matter what kind of emission mask texture is applied?
     
  46. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    When I use an area light I get this error on second time building lightmap :

    NullReferenceException: Object reference not set to an instance of an object
    ftBuildLights.BuildLight (BakeryLightMesh obj, System.Int32 SAMPLES, System.String outName) (at Assets/Editor/x64/Bakery/scripts/ftBuildLights.cs:266)
    ftRenderLightmap+<RenderLMDirect>d__189.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:4918)
    ftRenderLightmap+<RenderLightmapFunc>d__176.MoveNext () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:3416)
    ftRenderLightmap.RenderLightmapUpdate () (at Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:2549)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)

    When I check the area light, I get the mesh renderer and mesh component attached without any mesh on it. These components are added upon rendering the lightmap, but after baking it for the first time successfully, they do not get destroyed..

    Any idea?

    -- Edit --

    I have fixed this issue by changing destroyimmediate call in the script.
     
    Last edited: Jan 28, 2019
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Really hard to say why it happens. For some reason the line is pointing to "throw" and not the actual place where the exception was caught. Can you try commenting out (adding "//" in front) following lines:
    - 984 and 985
    - everything from 3503 to 3511
    Console should then report the proper cause (different line).

    My bet it's still 0.125. You world is literally ~313134696000 cubic meters and you're asking Bakery to have 2 texels for each. That would require a sqrt(313134696000*2) = ~791372x791372 texture. I understand there are likely large empty gaps in the scene, but still any large structure (an asteroid?) can potentially take insanely large resolution.
    Set Texels Per Unit to 0.125 or less.
     
    frankadimcosta likes this.
  48. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Some details are here: https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-45-released.536008/page-34#post-3953812

    All emissive pixels of the mesh will emit light the same way, no matter how they are calculated. You can even use a shader with procedural emission. However, in case of custom shader, it's important that you set material.globalIlluminationFlags to MaterialGlobalIlluminationFlags.BakedEmissive

    You probably had AreaLight + LightMesh + MeshRenderer all on the same GameObject. This was fixed. But for now either use LightMesh+AreaLight or LightMesh+MeshRenderer.
     
  49. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    The city map has 5 texels. But many objects and "fake terrain" cubes are not static, so the size of the scene is not so HUGE !
     
  50. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    Great thanks @guycalledfrank. Just gunna repost this because I ninja-edited just as you replied:

    additonal question: if I want to pack all scene geometry into one lightmap I think I add a Lightmap Group to a parent gameobject set to 'pack atlas' - cool. However when I do this I seem to lose the ability to adjust overall lightmap resolution ('texels per unit') in the lightmapper settings. Is that right? Am I missing something? Do I need to adjust the scale in lightmap for each mesh renderer individually?