Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

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

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

  1. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    It should. I don't have SLI, but at least 2 people in this thread confirmed it uses both GPUs. CUDA driver is supposed to do that, and I'm glad it does :)

    Didn't add one. Noted. But yeah, you can easily patch it to RenderLightmapFunc for now.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,169
    Any timeframe when you aim to support "Directional lightmaps (bump, specular)" ?
     
  3. Muuuuo

    Muuuuo

    Joined:
    Apr 16, 2015
    Posts:
    57
    I tested this again on a different PC target project and aside from few issues and occasional crashes I got it working with very nice baking quality.

    Some issues I encountered:
    - Got the attached image error when I tried to bake and it wouldn't proceed, reopening unity fixed it for good.
    - Got the same "You need to mark some objects static or add Bakery Lightmap Group Selector components on them", but this time only when trying to bake light probes (normal GI bake worked fine). It got fixed after I tried to increase the texel resolution from 20->60, increased samples from 16->24 and attempted to bake reflection probes once which failed with random pptr errors. I have no idea what's going on with this.
    - Few times (maybe ~5% chance) unity will crash when starting a bake
    - Another seemingly random UV related error that appears only sometimes when baking. The error makes the bake freeze forever. Reopening unity several times and clearing baked data manually makes it work sometimes. Attached a pic.

    Once the weird bugs are squashed the asset is definitely production ready. :)
    Excited for the future of the project!
     

    Attached Files:

    Last edited: Aug 21, 2018
    guycalledfrank likes this.
  4. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    What! You got shadowmasking that fast!!!
    I may not be able to content the hype! Im preimplosion shaking lol.
     
    guycalledfrank likes this.
  5. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Less than a month, I think.

    OK, I think I fixed this one recently - should be fine in the next version.

    Aaand this one too. For quick fix see this post (google drive link): https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-1-released.536008/page-8#post-3602916

    Not sure about other errors - will debug more.
     
  6. JohanL

    JohanL

    Joined:
    Apr 15, 2013
    Posts:
    12
    Awsome!

    Another issue i've come across is that it currently doesnt bake the light probes correctly, I dont' know if I have some settings wrong because its baking fine, but all the probes come out with the same ambient color.
     
  7. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    581
    Seriously. I can't wait to see what multi video cards can do.
     
  8. JohanL

    JohanL

    Joined:
    Apr 15, 2013
    Posts:
    12
    The light probes seems to work fine after further testing, but they don't seem to add the indirect bounces of the directional light.

    How should I apply my settings to get the equivalent of mixed lighting in plm/enlighten?

    Right now i'm only baking indirect light while using a directional light with real time light, is this correct?

    I have a skylight and the bakery directional light.

    edit:

    Now when I choose "Full Lighting" I get the error "you must mark some object static" when trying to bake light probes.

    edit2:

    Actually seems like I get the error when the directional light is marked as "Bake to indirect".
     
    Last edited: Aug 21, 2018
  9. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    581
    Sorry, you probably answered this already, but will this work for HD also?
     
  10. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
  11. sbsmith

    sbsmith

    Joined:
    Feb 7, 2013
    Posts:
    76
    Great! Thanks for the confirmation. I'll report back about how it goes.
     
  12. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Lightmapper only calculates direct/point lights for probes.
    GI, area lights and skylight are instead rendered as cubemaps inside Unity and downsampled to probes. So if your probes can SEE lightmapped meshes with light bounces, they will reflect them. If you render probes in a non-lightmapped scene, they won't get any GI. This is currently how it works, because it seemed like a natural way to do it while also easily respecting radiance from all custom shaders - I may unload more parts of it to the lightmapper in the future.

    HDRP? Yes!
     
    Mark_01 likes this.
  13. skyecrack

    skyecrack

    Joined:
    Jan 5, 2018
    Posts:
    29
    Hi, I'm very interested in getting this asset. Now, I'm considering to buy this to avoid using Enlighten in the "open world" sequence of my game, and since I need little to no directional lighting there, can I use this to bake several ambient only maps and fade through them? Also, are all lights stuffed into one single lightmap for a whole scene or you calculate them individually for each light and it's range of influence? In other words, can you do direct specular stuff with it? Because that'd be hard to resist.
    And what about streaming lightmaps? How would you do that with your lightmapper?

    Not to confuse you now, I'm trying to get a grasp on is this just a baking tool or a more fleshed out lightmap solution.
     
  14. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    How large is it? Personally I would avoid using lightmaps in HUGE open worlds, because it may require way too many textures/memory. Something of the size of Deus Ex or even Quantum Break might be fine, but not a Skyrim-like world.
    For big maps often it's a good idea to bake interiors but use different technique outside.

    You can bake sky lighting and GI only. By "fade" do you mean using multiple different maps per object and interpolating at runtime? If so, it's possible, but you'll need to write your own shader and set textures per object manually.

    I'm adding Shadowmask support right now. It works by calculating full bumpmapped/specular lighting in real-time and then multiplying it by baked shadows. So you get all fancy effects but don't have to pay for real-time shadow rendering (except for dynamic objects). Note that it means specular can be only cast by lights Unity supports = directionals, points and spots.

    How about streaming built-in lightmaps in Unity? How about streaming any textures in Unity? No idea. I wrote a native dx11 library for it once, but it's out of scope for this project.


    Shadowmask in action (mixing real-time character shadow with baked):


     
    ftejada, CoastKid, Gametyme and 10 others like this.
  15. skyecrack

    skyecrack

    Joined:
    Jan 5, 2018
    Posts:
    29
    Well, it's not exactly your typical open world map (hence the quotation marks), more like a vast semi-cultivated wildland with a small city/village as a revolving point. Not really Skyrim-like in the end but ambitious never the less. I've been pondering back and forth on how to solve the outdoor shading and the most viable solution would no doubt be occlusion probes that Unity rolled out (?) for 2018.2, but being stuck on 5.6 cycle that's not an option (unless I spend like 5 months trying to learn how to break the code down and adapt it for 5.6). Vertex lightmapping would be the second best thing.
    And I'm bound to Enlighten as far as indoors goes.


    Yeah, like that. But in a sense of accessibility of data. We post-Beast fellas aren't really used to it. :/


    Yay! Will get soon, then.


    Amplify Texture?
     
  16. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    How are you shader skills? You can try something like pre-rendering scene top view into low resolution depth maps and then running something similar to SSAO. Because of using top depth instead of view depth, it will be world-space (won't move with camera) and will give you nice darkening from the sky.

    Also I'm afraid shadowmask only works on 2017.3 or newer :(
    There is simply no API in Unity to set it in earlier versions.

    That can help, although note it doesn't work for terrains, only for meshes.

    Bakery lightmaps are regular textures, so if Amplify Texture works for you, you should be able to stream lightmaps.
     
  17. skyecrack

    skyecrack

    Joined:
    Jan 5, 2018
    Posts:
    29
    I successfully created a noise effect a few years back. :D Have most of it in theory but never had the time nor the patience to delve into practical applications of anything I research on the topic.

    You mean to rewrite an SSAO effect to read top camera depth instead of view camera depth and just apply it to my view camera?


    ???


    What about LODs?
     
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Sort of yeah. I think GTA5 did something similar, or at least I found they were using tiny top-down depth maps there, maybe even just applying them as simple shadowmaps: https://imgur.com/a/bKVTlFl

    Shadowmask was exposed in Editor since 5.x, but there was no scripting API for it. Specifically, I need this property to assign shadow masks: https://docs.unity3d.com/ScriptReference/LightBakingOutput-occlusionMaskChannel.html
    You can see it's not in the docs before 2017.3, and my 5.6 doesn't understand it. MAYBE there is some hacky alternative, but I haven't found it yet :(

    ... ooh wait, I've just realized it might be there, but private and called m_BakingOutput instead. I'll check it. There is hope!

    Not supported YET, but planned.
     
    skyecrack likes this.
  19. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    OK. I can´t seem to guess this and there are some "missleading" phrases that make me think that---> Within realtime shadow range (quality settings) the dynamic objects will not receive shadows from static objects? Please tell me I'm wrong :D

    red flag alert phrase:
    "So you get all fancy effects but don't have to pay for real-time shadow rendering (except for dynamic objects" :confused:

    Example: I'm running with a tank from a city with static buildings... Will the buildings withing the realtime shadow area cast shadows onto the tank?
     
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    They will, if you have "Distance Shadowmask" enabled in quality settings. In this mode Unity renders all shadows dynamically within the range. As it ends, it falls back to normal shadowmask mode (as on my pics).

    Here is with distance shadowmask (although my geometry is full of holes and it doesn't look great... but you get the idea):

    photo_2018-08-21_20-37-46.jpg


    YES, I think I managed to make shadowmask work on 5.6! For future generations, here is the hacky code:

    #if UNITY_2017_3_OR_NEWER
    var output = new LightBakingOutput();
    output.isBaked = true;
    output.lightmapBakeType = LightmapBakeType.Mixed;
    output.mixedLightingMode = MixedLightingMode.Shadowmask;
    output.occlusionMaskChannel = occlusionMaskChannel;
    light.bakingOutput = output;
    #else
    light.alreadyLightmapped = true;
    light.lightmapBakeType = LightmapBakeType.Mixed;
    var so = new SerializedObject(light);
    var sp = so.FindProperty("m_BakingOutput");
    sp.FindPropertyRelative("occlusionMaskChannel").intValue = occlusionMaskChannel;
    sp.FindPropertyRelative("lightmappingMask").intValue = -1;
    so.ApplyModifiedProperties();
    #endif
     
    TooManySugar and skyecrack like this.
  21. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    Based on what you are showing here, it looks like you also have specular / roughness working, is that true? If so, what is your timeline?
     
  22. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Superb!!! I can´t believe this is going to make it on time for my game>> You're the best!!
     
    Last edited: Aug 22, 2018
    guycalledfrank likes this.
  23. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Let me explain how shadowmask works in a formula:
    lighting = bakedIndirect + realtimeLight * realtimeShadow * bakedShadow

    So we have baked GI and baked static shadows in separate textures. It makes it possible to blend static and dynamic shadows together AND because unshadowed lighting is real-time, to have bump, specular and all that stuff.
    In fact, here is a graph for you:

    smaskexplanation1.jpg


    As you can see, indirect lighting currently doesn't affect bump/specular, but will after I add Directional lightmap support. For direct lighting it's not a problem.
     
  24. JohanL

    JohanL

    Joined:
    Apr 15, 2013
    Posts:
    12
    The problem is when I have the directional light marked as being baked into the indirect lighting I cannot bake light probes because it says I have nothign marked as static in the scene. This is after I baked the lighting in the scene.
     
  25. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    That should be fixed in the upcoming version.
     
  26. JohanL

    JohanL

    Joined:
    Apr 15, 2013
    Posts:
    12
    Awsome!

    Sorry for being really insistent about this but I do think there is an issue/me doing something wrong with how the settings for light should be for the probes to work properly.

    The left one is probes baked with Bakery and the right one is probes baked with the PLM, as you can see the directional light hardly contributes anything to the lightprobes in the left one even tho I've increased the intensity of the light significantly. The scene bakes perfectly and I get a nice indirect light from the directional light, but the light probes doesnt seem to sample it.

    Maybe its just more accurate then the PLM lightprobes? But they do seem to pick up on variance in the environment alot more then what bakery does.
     

    Attached Files:

  27. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Probably the other way around. Spherical harmonics are pretty complicated and I'm not sure if I got probes completely right. If you can combine PLM probes with Bakery lightmaps, then do it. I will work more on probes in the future.
    Lightmaps are the main product and they should be perfect.
     
    Mark_01, GT_salif and TooManySugar like this.
  28. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Turns out, it's not so easy. This method works in Editor, but not in builds, because there is no SerializedObject. Banging my head and trying to find another way, but not sure there is any.
     
  29. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    May be try contact unity via bug report. Usually an skilled person reads and answers.
     
  30. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    It's not a bug - SerializedObject is a part of UnityEditor namespace, and it only exists in Editor by design. But so far it's the only way I found to get to the occlusionMaskChannel property in < 2017.3 versions.
     
  31. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,388
    You could maybe get access using Reflection.
     
  32. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Tried that already - it's not there. Checked all non-public fields/properties.
     
  33. g8minhquan

    g8minhquan

    Joined:
    Jun 18, 2014
    Posts:
    38
    After I use Bakery, my friend (who has Intel integrated VGA) checked out my project and he got a very long loading when run the game on editor. He didn't have this issue before Bakery so I guess he has issue with reading Bakery's data without an nVidia VGA?
     
  34. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Streaming textures came out with the latest version of unity 2018.2 but havent tried it myself...dont know how theyre working, and if theyre working ok with lightmaps textures or just with others textures...anyway heres some docs of unity about it

    https://docs.google.com/document/d/1P3OUoQ_y6Iu9vKcI5B3Vs2kWhQYSXe02h6YrkDcEpGM/edit
     
  35. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    How many lightmaps are there? Can be a problem with insufficient memory on his PC. Bakery lightmaps are regular Unity textures after bake.
     
  36. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    52
    I'm trying to use the Vertex LM shader but it only has one UV set, how hard would it be to add the equivalent of the Secondary Maps from the standard shader?
     
  37. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Hey dev, may be, aside of the shadowmasking for older Unity versions already there are enough fixes to justify an update as several of reported issues are fixed in the latest non public version. Plus people working on modern versions can test the shadowmasking and report possible issues. Meanwhile you can keep looking for the way to implement in older versions if there is any chance.

    In thestore says it works with 2018.1, I've been using it in 2018.2.0f2 since start so I guess you could extend known compatibility to that version too.

    But hey just saying, if you see a chance to implement shadowmasking in the "short" time you may get a higher impact releasing that way. (yes I 'm eagerly waiting to test it :D)
     
  38. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Fair enough. But just today I managed to partially reverse engineer LightingDataAsset and patch it with shadow mask channels, and it works in builds on 5.6 :)
    Almost ready to release. I know I got carried away with this complete shadowmask support, but it's aaalmost done.
     
  39. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Sorry, missed your question. Yeah, current vertex lightmapped shader is just an example. Originally I thought of extending Standard shader with vertex LM, but there are multiple problems:

    - You can create a copy of Standard shader with additional features, but it will be doomed to break on different Unity versions. For example. here is a nice shader that multiplies albedo with vertex color (albedo tint, not vertex LM), and I tried using it in my projects, but found you need to make a different version for almost every version of Unity. A lot of shader variables get renamed, function start using different parameters, etc.
    - You can patch built-in shader includes, so all shaders use them. This is what Shader Tweaks menu does. However, adding vertex color is not trivial, it would require additional vertex interpolator, and it can be already used by a shader, so some shaders can break. Not an option.
    - HDRP is not even compatible with Standard shaders, meaning I would have to provide another compatible shader that works.

    All in all, it's pretty complicated. If you're using custom shaders and can understand them, it's easy to analyze my vertex LM code (literally 3 lines) and add it to yours.
     
    Mark_01 likes this.
  40. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    286
    Hi I have a question

    I have this nearly identical rooms, the only difference is one has an emmisive material as light source the other has a point light.

    they both have static and dynamic meshes (the balls outside are dynamic)
    they both have a matrix of lightprobes
    they both have a reflection probe

    upload_2018-8-23_17-3-13.png

    If I bake Only the red room with the material, everything works fine
    If I bake both, everything fine
    but

    if I bake Only the white room, and then try to bake the LightProbes, it says this

    upload_2018-8-23_17-7-58.png

    But the Lightprobes render just fine if I simply enable the other room

    Any idea why?
     
  41. Xeverian

    Xeverian

    Joined:
    Sep 23, 2016
    Posts:
    12
    So I've purchased the asset yesterday and played with it a bit in 5.6.3p1. I'm really glad now that I got that 1080Ti ( :
    However I've noticed some bugs:
    1. Crashes upon baking any other time I'm pressing the bake button while the scene is not saved and choose 'yes' to save it no upon bakery's message. If I save the scene manually each time I change the baking settings it doesn't crash unity.
    2. Some of the objects on the scene getting some weird colors like pink\red\blue instead of their actual textures from time to timeupon the bake. Cleaning baked data doesn't help and the only way to fix it was hitting bake on the default Unity light baker even if the only light on the scene is marked as realtime.
    3. The lightprobe baking bug described in the message above by daville. Sometimes they just don't bake.

    I see that some of these bugs may have been fixed already so I'm looking forward for the update. My scene has pretty much every object LODed so I can't really use the asset as of now. Hopefully you're planning to bake separate lightmaps for different LODs like in progressive lightmapper instead of just LOD0 and light probes for other LODs as it is done with enlighten.
    Also even though I can kinda live without the shadowmask I'd really love to have it on 5.6. So I guess as of now one can't use mixed lights with Bakery? And could you clarify the workflow a bit: after the bake is done, do I disable the Unity lights or do I keep them? Without them my dynamic objects are just plain black and with them the scene looks like kinda overlighted and there's no mention about what we should do with the lights in the manual so I'd really like to get some explanation.

    Overall its a really promising asset so I look forward for the updates and gonna rate it on the asset store as soon as the features I need will be implemented
     
    Last edited: Aug 24, 2018
  42. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    All I can say is: wait for the upcoming version. Give me 2 days and another 2 days for the store to approve it.
    Quick fix for crashes - replace this file: https://drive.google.com/open?id=1338poM8Zt1NLtErnCy5TmxlZ0WCqK4WY

    Does pressing "Update skybox probe" help?
     
    daville likes this.
  43. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    You can bake in Indirect mode. In this mode:
    - All lights without "Bake to indirect" checkbox only get their indirect (GI) contribution baked.
    - All lights WITH "Bake to indirect" are baked completely.
    That means if you have e.g. sun, and bake it in Indirect mode, you'll have baked GI, but can also use real-time Unity light for directional contribution.

    If you have both Unity and Bakery lights on the same object and
    1. You are baking in Full Lighting mode, then you should disable Unity light (after or before the bake, it doesn't matter).
    2. You are baking in Indirect mode, and "Bake to indirect" is OFF, then leave it, because it's not completely baked.
    3. You are baking in Indirect mode, and "Bake to indirect" is ON, then disable Unity light, because it's baked like in Full Lighting mode.
     
  44. Xeverian

    Xeverian

    Joined:
    Sep 23, 2016
    Posts:
    12
    Yeah it seems to work

    That sounds good. Gonna definitely check the update. Meanwhile I look forward for all the important features like LODs and directional light maps support ;) unfortunately I can't use bakery in my project yet because of that but I've decided to buy it now as I can see the progress and a lot of work you put in it, so good luck with further developement and hopefully I"ll be able to use Bakery soon enough :)
     
  45. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    286
    Hi, One question, Do you have any plans to support the standard Unity Skybox procedural shader? or similar?

    My workaround so far, is create an empty scene with the skybox settings I want, and use a Reflection Probe to bake it and generate a Cubemap, and then use that cubemap in Bakery Sky shader.
     
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    Wasn't planned. ReflectionProbe method is the only way that comes to mind. I could automate it via scripting, but not sure it's worth it.
     
    daville likes this.
  47. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,417
    I'm updating the docs and waiting for a few people to test the new version. Hopefully will publish tomorrow.

    Meanwhile, did I mention that vegetation and vertex lightmaps are suuuch a good fit? :)

    ftvtx2.jpg ftvtx.jpg
     
    fuzzy3d, ftejada, CoastKid and 5 others like this.
  48. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Awesome!!!!!!!!!!, weekend is awesome for baking with higher than usssual values as it can be left while you leave.
    In future I would love to see a queue so we can add scenes and left them baking with super high sample values for the final version and let the machine for a whole weekend or a week if needed.
     
  49. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    May be for larger scale it would make more sense realtime Screen Space Shadows. But I can see this be an option for smaller bakes.

    Something like this
    https://github.com/keijiro/ContactShadows
     
    guycalledfrank likes this.
  50. Crusare

    Crusare

    Joined:
    Feb 14, 2014
    Posts:
    21
    Hi there!

    So I've purchased Bakery today and have set up a very simple test scene (just one directional light, one plane and one 3D object). Added the corresponding bakery script to the directional light and then hit render in the bakery window with default settings. After a couple seconds, the screen turns to black. This black screen stays for a while, after which the desktop shows up, along with this error message:

    https://www.dropbox.com/s/f8av6qsqft9nh7g/Error.png?dl=0

    Is there anything I can do to get around this?
     
unityunity