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

    OlliIllustrator

    Joined:
    Nov 1, 2013
    Posts:
    71
    Thank you for the list with the minimum scripts. That really helps.
    The minimum scripts installed into my project without problem.
    Bakery is too good not to use it in the project and it is cool that the crash conflict (whatever it is) will not keep me from it:)
    Baking in a separate scene and then moving the asset and/or the maps is totally Ok.
     
    guycalledfrank likes this.
  2. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi,
    Is it possible to add already the shader subgraph for HDRP (support for per-vertex, RNM and SH lightmaps)
    to this Shadergraph version of the HDRP/Lit shader https://github.com/RemyUnity/SG-HDRP-Lit.

    I am doing some nice tests with the Spaceship Demo and it would help a lot.


    Here the test so far....

    i selected all the baked and mixed lights in the Light Explorer,

    Lights.JPG

    - added per multi selection Bakery Points Lights to it.
    - clicked "Match lightmapped to realtime for all lights"

    Bakery_Light.JPG

    - saved the scenes where the lights are in
    here SpaceShip_LI and Spaceship_Wrecked_LI
    This scenes also include the lightprobes and the reflection probes


    Scenes.JPG

    - the activate Spaceship .scene on the top.

    - hit Render

    - question: this error is spawned with every light
    er.JPG

    Is this errors due to there is no SkyLight in the scene?

    to be continued.....
     
    Last edited: Dec 15, 2019
  3. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    question in between
    HDRP 7.1.6 in Unity 2019.3.0f3
    Bakery 1.65
    and
    BakeryShaderGraphHDRP_3.unitypackage

    i added
    to

    Non-directional
    material demornormal_ND with HDRP Lit and NormalMap

    Dominant Direction
    material demornormal_DD with HDRP Lit and NormalMap

    RNM
    material demornormal_RNM with HDRP Shadergraph BaqkeryRNMGraph and NormalMap

    SH
    material demornormal_RNM with HDRP Shadergraph BakerySHGraph and NormalMap

    Baked Normal Map
    material demornormal_BNM_BD with HDRP Lit and NormalMap

    this is my result

    Did i do it right?


    example_mixed_directional.JPG
     
  4. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    sorry for flooding the Thread....

    There raised another question.

    HDRP 7.1.6 in Unity 2019.3.0f3
    Bakery 1.65
    and
    BakeryShaderGraphHDRP_3.unitypackage


    I added your BakerySpecSHGraph
    to the
    Shadergraph clone from the HDRP LIT (SG-HDRP-Lit-master)
    https://github.com/sasa42/SG-HDRP-Lit?organization=sasa42&organization=sasa42

    and injected the
    Base/Detail Normal Blend output (red marked)
    to the
    NormalWorld input (red marked)
    from your Custom Function.

    This should be an full clone of the HDRP LIT Shader as Shadergraph HDRP LIT + BakerySH.

    Bakery_LIT_Shadergraph_SH.JPG

    I get this output.
    Does it look right for you?

    I only added an lightmap group to the ground plane with SH override.

    LMGroup_SH.JPG


    Somehow the emissive red cross get little lost. Shadow Mask Bake.

    Bakery_LIT_Shadergraph_SH_result.JPG

    and the result on Plane_SH. Full Lighting Bake.

    Bakery_LIT_Shadergraph_SH_result_02.JPG
     
    Last edited: Dec 16, 2019
  5. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    So since 5.0 Unity moved lightmapIndex (and scaleOffset) from the scene file to this black-box lighting data asset. Even worse, the value is never serialized when set from a script, so this data can't be patched:
    https://support.unity3d.com/hc/en-us/articles/206869046-Using-external-lightmaps-in-Unity-5-0

    Every time the scene is reloaded, the values are reset to lighting data asset data. To work around this limitation, Bakery performs steps similar to the link above: first it re-assigns indices/scales/offsets on Awake(), then it also re-assigns indices in Start() again, as it seems like when multiple scenes are loaded, Unity rearranges the IDs one more time.
    Bakery also has to rearrange them in multi-scene setups.

    So the final, "stable" IDs are set after Start. If you load multiple scenes and need exact used IDs, it's best to wait for the first Update().
    If you don't need IDs or if you actually need the lightmaps used on each object, not the volatile IDs, you can access Bakery storage object directly:

    var storage = GameObject.Find("!ftraceLightmaps").GetComponent<ftLightmapsStorage>();
    storage.bakedRenderers // list of renderers
    storage.bakedIDs // list of initial IDs per renderer - shouldn't change unless you load multiple scenes
    storage.bakedScaleOffset // list of scales/offsets per renderer
    storage.maps // list of lightmap textures addressed by bakedIDs
    etc


    "Baked contribution" hides when in Full Lighting mode, as it doesn't affect anything. it should be visible on Indirect/Shadowmask mode though.

    Hmmm... does it happen if you replace terrain with a plane? I.e. is it a general shadow artifact or terrain-specific?

    I think it should be possible - my subgraphs only write to the "override baked GI" output for diffuse and to emission to specular. You can use an "add" node to combine different emission.

    Definitely not related to skylights. The error is only shown if light projection mode is set to "cubemap" but no cubemap is set:
    if (light.projMode == BakeryPointLight.ftLightProjectionMode.Cubemap && light.cubemap == null)


    Since you used the "match" button, the cause is here:
                        if (light.type == LightType.Point)
    {
    if (light.cookie == null)
    {
    ftraceLightProj.enumValueIndex = (int)BakeryPointLight.ftLightProjectionMode.Omni;
    ftraceLightTexture.objectReferenceValue = null;
    }
    else
    {
    ftraceLightProj.enumValueIndex = (int)BakeryPointLight.ftLightProjectionMode.Cubemap;
    ftraceLightTexture.objectReferenceValue = light.cookie;
    }
    }



    It seems like your point light has a cookie texture, which assumed to be a cubemap. But... is it?

    Apparently not. Here, I tried it myself:

    upload_2019-12-16_15-52-9.png


    Used single HDRP Lit + Normal Map for both non-dir, dominant dir and baked normal maps, BakeryRNM material for RNM and BakerySH material for SH (I changed albedo color to white in BakeryRNM/SH graphs to match).

    Apparently I you rebake, baked normal maps starts looking like non-dir, because the export script (ftUVGBufferGen.cs) is expecting normal map to be called "_BumpMap". Replacing it with "_NormalMap" gives correct results.

    upload_2019-12-16_15-56-37.png

    ... will add a fix to account for both names.

    I bet your code outputs tangent-space normals, not world-space. Check PerPixelWorldNormal subgraph to see how one can be converted to another.

    Yes - emission intensity is different in HDRP, you should boost it up.
     
  6. RegdayNull

    RegdayNull

    Joined:
    Sep 28, 2015
    Posts:
    66
    Yes. Appears only on terrain.
     
  7. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937

    First. Thanks for all the valuable input on point.
    It worked out everything!

    Here a Area Light Bakery conversion problem i came across...

    Close to all baked Area lights (more than 20) have no mesh renderer.
    The selected one and all others under it.
    They only have the Rectangle Shape from Light settings.

    Area_without_mesh.JPG

    ....so i added a Bakery Point Light. Because Bakery Light Mesh needs a mesh.

    Area_without_mesh_light.JPG


    However there are 2 Area Lights with an mesh renderer who allow the use of Bakery Light Mesh.

    Area_with_mesh_light.JPG


    Is it a "curently not implemented thing"
    that Bakery Light Mesh cannot take the Rectangle Shape from an HDRP Area light?
     
    Last edited: Dec 16, 2019
  8. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi.
    Probably you can have a fast look.
    I included all 3 Materials in the package for an fast toogle.
    (I only added an Directional Mode SH, Shadowmask, Resolution 4K lightmap group.to the ground plane)

    HDRP_Lit

    00_HDRP_Lit_Standard.JPG

    HDRP_LIT_Shadergraph
    (a Shadergraph version who looks the same like the HDRP Lit. Great.)

    00_HDRP_Lit_Shadergraph.JPG

    BakerySH_HDRP_Lit_Shadergraph
    (i integrated your Bakery_SH with the PerPixelWorldNormal fix to the HDRP_LIT_Shadergraph)
    02_Bakery_SH_HDRP_Lit_Shadergraph.JPG

    The ground gets slighly brighter. I am not sure if this is correct due to the SH addition or some normal issue.
     

    Attached Files:

    Last edited: Dec 16, 2019
    guycalledfrank likes this.
  9. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Can you check if changing "terrain optimization" option in advanced settings fixes it?

    It actually can use a rectangular area light component instead of a mesh. Even the match button should work. So use it, not the point light :)
     
  10. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Sometimes I get this result (white lightmaps), other times it bakes normally, any idea where the problem can be? The scene is indoor cave with several point lights and 6 baked Directional lights with no shadows as ambient source.

    EDIT: when decreasing Texels per unit, lightmaps are baked correctly
     

    Attached Files:

    Last edited: Dec 17, 2019
  11. Daugvydas

    Daugvydas

    Joined:
    May 23, 2019
    Posts:
    2
    Hello, I have baked prefab in one computer, and need to manually move it to another PC. What is the right way, which files would i need to move? For now i tried the prefab itself and lightmaps from the scene where it was baked, what else should I move with it? any light data file or something like that?

    upload_2019-12-18_11-21-22.png upload_2019-12-18_11-20-39.png
     
  12. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Is the whole cave completely white? Do you have any very bright light sources or emission, or lights with very high Indirect Intensity value? I've seen colors overflow in such cases, although usually the result was black.
    Are there any strange spots when the bake is fine? I.e. something where the bright light seems to be spreading from?
    Can it happen without GI?

    Generally to exchange prefabs between different computers you should use unitypackages. Simply copying the prefab file usually doesn't work, as asset reference IDs won't match.
    In case both computers have Bakery installed and Unity/Bakery version is the same, it should be sufficient.
     
  13. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Whole cave is white - all lightmaps are white. Lights have intensity 0-2 + some HDR emissions with multiplier of 2. On resolusion of 9, the bake is ok (no spots). On resolution 10, everything goes white - no errors in the console.
     
  14. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    If i do so i get this error and Rendering lightmaps - preparing stops here....

    RectangleAreaLight_MeshLight.JPG
     
  15. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    Thank you Frank, you are the best, very helpful information. That array is definitely something else ! :(
     
  16. ViewportAU

    ViewportAU

    Joined:
    Mar 26, 2014
    Posts:
    26
    is it any plans to support double side materials like for instance for plants? This example is by ArchViz pro 7 HDRP ... Also, feature request: Variable to Increase or decrease global Light Probe brightness. That would be very handy, as I have noticed Light Probes normally gets darker than it should be. (no, I don't have light probes behind surfaces)
    upload_2019-12-19_18-7-10.png
     
    Last edited: Dec 20, 2019
  17. RegdayNull

    RegdayNull

    Joined:
    Sep 28, 2015
    Posts:
    66
    Yes. Uncheking this did the trick.
     
    guycalledfrank likes this.
  18. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    Does bakery perform quality light map clustering and packing too? My biggest issue with unity's light mapping is how ineffectively and inefficiently it clusters and packs baked light maps.
     
  19. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    There are 2 options. Default and XAtlas.
    Here is the packing for LightMaps with Xatlas with 80 Texel per Unit resulting in a bunch of superior packed lightmaps,directionals(screenshot) and shadowmasks at 4K for the Spaceship Demo in Shadowmask Mode (52min, RTX 2080)

    XATLAS.jpg

    I did not managed to rebake the scene with Unity Progressive GPU and i tried a lot.
    It falls back to CPU with 10, 20, 40 (scene default) texels per unit.

    Progressive.jpg
    It seems they baked the scene defaults from 40 texels with an Quadro 8000 and 48GB RAM.)
     
    Last edited: Dec 20, 2019
    guycalledfrank likes this.
  20. JodyMagnopus

    JodyMagnopus

    Joined:
    Sep 17, 2016
    Posts:
    13
    I tried to make this into an installable Package Manager package with a package.json and everything but it had issues working because the ftlocalstorage asset is created within the package directory and causes an issue where Unity says there is a missing meta file for ftlocalstorage.asset. It would be better if something like localstorage could install in a different folder such as StreamingAssets or a folder guaranteed to be in the Assets folder rather than in the package folder.

    You can see this page for details on how to make/use such a package:
    https://docs.unity3d.com/Manual/CustomPackages.html

    At Magnopus we like to use packages because it lets us easily install everything we use and to set up dependencies of one package on another.
     
  21. bansheesoft

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    62
    Again AWESOME add on thanks Mr. F. Wanted to save others time if they run into a problem with my network render fix.
    I had to put a Thread.sleep into ftClient to avoid socket spamming on my render pc. I tried to make a WebGL build and was getting strange errors when trying to load it from the website. DLOpen errors. Once I removed the System.thread and sleep it went away. It took a bit to figure out so I wanted to save others time =). I had to remove oculus as usual also for WebGL builds.

    Thanks again!
     
    guycalledfrank likes this.
  22. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    39
    Hi Frank,

    Been using Bakery for quite some time and we are including into our pipeline in all our projects, so thank you for your work and dedication, it means a lot to us. I have periodically check this thread, so I'm sorry in advance if some of my questions have already been answered.

    I'll report a few things we have noticed as bugs, and ask you a couple of hard questions :)

    1. IES spotlights - they give a strange bright-line sometimes on the edges of the spotlight. We have solved this by putting shadow spread to 0, but this probably should not happen.

    2. Light mesh - we have noticed a strange leak all over the lightmap when Self shadow is on. One small light leaks color all over the lightmap - changes the color of the entire lightmap, even in the room that does not contain the light. The power of the light is very week compared to the leak it makes. When I say leak, it is not a leak like on the edges of texels leak, but rather the whole lightmap gets yellow color for example. This is happening on the second bounce pass, not on the first one.

    Now for the hard questions:

    1. We need to load IES file dynamically (for now from the editor script) and assign it to Bakery. Saving the file into the folder and assigning it as an object doesn't work. Best is not to save the file, so we don't burden the assets folder. We have the file in the text format in the memory. Is there a way to forward it to Bakery?

    2. As we are using Bakery in a two-pass system, is there a way to keep UVs generated in the first pass with proper lightmap number assignment (but without using Lightgroups), when Bakery is run for the second time. (model is dynamically loaded into the editor)

    3. (which might answer 2 as well) Is there a way to export the scene and send it to network bake from run-time? This is the most important issue for us. So, we would run our own server that would accept requests for baking and then, one by one direct it to the Bakery server, fetch the lightmaps when they are finished and send them back.


    Thanks Frank!
     
    guycalledfrank likes this.
  23. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    **EDIT SOLVED**
    turns out it was my custom render pipeline, the matrix was flipped, changed the check for LWRP / HDRP inside ftUVGBufferGen to look at `bool isSRP = RenderPipelineManager.currentPipeline != null;` though depending on the user's pipeline their matrix may not need flipping



    getting a bug in stock 1.65 & 2019.2.15f1 where when using LM Group Selector no indirect / bounce lighting is baked (full lighting mode), using the lightmapped prefabs also.

    It seems to come and go, and once the bug is occurring it stays broken even after restarting unity and re-creating the lightmap groups.

    Trying to find more info & breakpoint where it decides to do the indirect lighting in code... It was also occurring in bakery 1.55 & then I updated to see if it fixed it.

    **EDIT** looks like it is related to the shader used, it is affecting the bake & causing no indirect light when in using a lightmap group. (very strange)
     
    Last edited: Dec 24, 2019
    guycalledfrank likes this.
  24. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Not sure I can think of any known cause. If you can provide me any scene where it can be reproduced, I will debug.

    Ah! It's a HDRP-related bug apparently. It seems like if you create an HDRP area light, then GetComponent<Light>().type is actually... LightType.Point! Bakery only uses data from the Light component (if not a mesh) to define area lights. Looks like HDRP instead stores area light properties in HDAdditionalLightData exclusively.
    I added a patch to github repo, can you try it?
    https://github.com/guycalledfrank/bakery-csharp/commit/ade3a2b73c2ee719e79ac8045c8bb5355eee4b56

    I can't bake different lighting to different sides, if that's what you mean - since that would require storing an additional UV set per vertex and only work with custom shaders. I mean it IS possible to implement, but I'm afraid no one will use it.
    You should check "Transparent selfshadow" option though, I always recommend using it on vegetation as it prevents it from looking dark when the normal is not pointing towards light: https://geom.io/bakery/wiki/index.php?title=Manual#Bakery_Lightmap_Group_Selector

    There is no such option, but you can easily hack it in the code. If you are using L1 light probes, you can change convL0 and convL1 variables in ftRenderLightmap.cs. Or if you are using Legacy light probes, change 5 variables starting with "irradianceConvolution" (multiply by anything lower than 1).
    Normally that shouldn't be necessary though. Maybe try the L1 mode, if you're using Legacy, as it doesn't rely on engine renderer and should match lightmaps exactly (it is also faster).

    No :D It is comparable to Unity's own packing at best. For serious production I recommend clustering and packing outside of Unity (Maya has great auto-packing). Unlike Unity, Bakery allows using pre-made combined UV atlases without doing any post-repacking.

    Note that these only affect the way individual objects are unwrapped, not the phase when their individual layouts are packed into a full atlas.

    That's actually pretty dense, nice!

    What are the benefits of package workflow though?

    But you can install regular unitypackage archives too (?)

    Thanks guys!

    There are lots of slightly different types of IES, I noticed problems with some as well. Will happily debug if you can send me the file you were using.

    I wonder if it was related to this (now fixed) bug? https://github.com/guycalledfrank/bakery-csharp/commit/5cb10adbc51523b978445ce178d5b0340f3bd33c
    Can you confirm the problem persists (or not) on v1.65?

    The way it currently works is:
    - ftBuildLights.cs reads iesFile field from BakeryPointLight object.
    - AssetDatabase.GetAssetPath is used to get file path.
    - ies2tex.exe is launched with asset path as argument. The file is read and converted to a cubemap which lightmapper then uses.

    "Saving the file into the folder and assigning it" should be the best solution, as ies2tex uses regular file API anyway. How does it fail exactly?

    Keeping asset UVs is easy (disabling Adjust UV padding), but keeping atlas layout (lightmapIndex/lightmapScaleOffset) is not, as it's recalculated on every bake. Do you want to replace existing model with no change to atlases (just replace this particular object's layout in the atlas)?
    Atlasing right now is the messiest part of the tool, I plan to revamp it completely.

    Scene export scripts use UnityEditor API. If, by runtime, you mean builds, then no; if you mean play mode inside Editor, it can be half-possible.
    Technically, even inside a build it is possible, but a lot of things need to be reimplemented. For example, even static flags ("Lightmapped static", etc) don't exist in builds, objects are often batched, etc. If you have a very concrete list of meshes you want to export, and you don't need to parse/filter the scene, the task is manageable.
     
  25. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    When baking bakery lightmapped prefab, whenever I click render, the m_ScaleInLightmap will become modified from 1 to 1 (no change), but it's a change according to the prefab, causing the error Prefab contains unapplied data error. any idea what is causing it?


    EDIT: I turn off occlusion probe that seem to help
     
  26. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    run into a problem with lightmapped prefab where all light become super bright..
     
  27. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    getting this error, now sure if its causing problem right now, whenever I bake, the file is automatically set to that error state
     

    Attached Files:

  28. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    GI completely broke after turning on custom gi location from editor preference. turn it off works again, just want to share that bug. i am using 2019.2.17

    edit

    now unity crashes whenever i bake :(

    edit:

    I think I hit save uv padding to asset and it's causing crash? I reset all the meta file of fbxs from before and now it stop crashing, but all the light stops working, the only thing baking is emitters


    edit: after many hours of trying different setting and delete library, finally I delete unity editor, and doesn't enable shader tweaks, and seems to go back to normal, I don't darte to turn on shader tweaks for now...
     
    Last edited: Dec 28, 2019
  29. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    I have this error, not sure what it meant.
     

    Attached Files:

  30. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    OK, that's weird! I've just tested baking prefabs with occlusion probes but didn't detect any problems. Also never got the "super bright" result. It would really help to fix it if you could provide a test scene/prefab (unitypackage) where the problem is reproducible.


    By the way: a couple of days ago I had to copy a group of baked objects and didn't want to mess with prefabs or rebake, so... I made a little script that just matches objects in two hierarchies by name and assigns lightmaps to the copy. Maybe it will be useful to you (file is attached). Usage:
    - Copy some object (with all its children)
    - Custom -> Copy lightmap
    - Set "source parent" to original game object
    - Set "dest parent" to the copy
    - Click Copy
    (- probably disable Lightmap Static on the copy to prevent it from getting a unique lightmap on next bake)



    Hmm. Can be the problem behind "super bright". What is your build platform and... did you change it after the bake? Bakery doesn't set any specific texture format, it merely gives Unity hints that it should be "default" and "compressed with high quality":

                    importer.textureType = TextureImporterType.Default;
    importer.textureCompression = TextureImporterCompression.CompressedHQ;


    Normally shadowmask assets should look like this (resolution can be different of course):

    upload_2019-12-29_12-28-7.png

    It could be that you baked using one build target, then switched it, somehow without forcing Unity to reimport assets; or possibly manually altered Format. Setting format to Automatic and reimporting these files should help

    What is "custom gi location"? Do you mean Unity's GI Cache? It is not really used by Bakery.

    Again, what is your build platform?
    Also regarding the "samplerunity_lightmap" - check if simply right click -> reimport on the shader fixes it or try disabling bicubic interpolation.
     

    Attached Files:

    Last edited: Dec 29, 2019
  31. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    my build platform is dx11 standalone PC, unity 2019.2.17f, I completely delete unity editor and reinstall, and didn't enable global shader tweak this time, and so far I can bake normally, the global shader tweak has been working for me for over a year, I don't know what broke the editor, could be because I turn on custom gi cache location in unity preference? turning off custom gi cache location didn't fix it, delete unity editor completely, fixed it.

    I created a new project with the same editor install that shader error doesn't show up, so I will continue to look for whats going on.
     
  32. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    right click on shader Reimport got rid of the shader error, but as soon as i make a stand-alone build the error comes back.

    only issue I run into now is the light bleed through walls where in editor it doesn't, i will give you update see if I still run into it
     
    Last edited: Dec 30, 2019
  33. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    hi can you post me the full screen of shadowmask should look like? mine looks like this:
     

    Attached Files:

  34. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    The most revealing bit here is naming. Bakery never calls anything "Lightmap-0_comp_shadowmask", but built-in Unity lightmapping does. You are likely looking at some leftover or unused shadowmask not generated by Bakery.

    Bakery shadowmasks have "_mask" at the end, and the rest is never "lightmap" or "comp" unless it is part of your scene or Lightmap Group name:

    upload_2019-12-30_11-54-23.png
     
  35. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    155
    Hey @guycalledfrank, I'm having an issue where two walls in a scene are no longer baking. Originally they were baking fine. I haven't changed any of the geometry or flipped any normals on them since. I've cleared all baked data. I've deleted all lightmaps. I've deleted and re-imported Bakery. All of this and it seems to remember my settings and keeps baking with the error. Is there a folder somewhere outside of Unity that stores information that I can clear to fix this, or any other suggestions?
     
  36. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    while I am trying to get it working, I keep deleting my lightbakefolder and start anew, so "Lightmap-0_comp_shadowmask" it not left over, it got generated whenever I use bakery, my unity auto generated light is disabled.

    I will just delete that file whenever it shows up for now, see if anything break.
     
  37. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Would it be somehow possible to have flat shaded Lightmaps? (except separate polygons in lightmap UV which leads to leaks)
     
  38. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    In simple mode (as well as anvanced mode with fix UVs), I get 3 object errors with overlapping UVs warnings. Also right at the end of baking, I get some weird error about an HDR file not being able to save

    upload_2020-1-2_17-57-29.png

    The console doesnt help much in exploring what the error may be about...

    Furthermore, my project is setup with URP and Bakery seems to set the mixed lighting to "shadowmask" during its build phase, but shadowmask is currently not supported in URP

    Any ideas?

    Here is my settings for the only light in my scene currently:
    upload_2020-1-2_18-5-14.png

    My lighting settings:
    upload_2020-1-2_18-6-17.png

    And my Bakery settings. I'm assuming the overlapping stuff in the UI is because I'm using 2019.3.0f3 and URP 7.1.7
    upload_2020-1-2_18-7-19.png
     
    Last edited: Jan 2, 2020
  39. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    ....also, I've got no idea what that means:

    upload_2020-1-5_15-50-49.png
     
  40. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    I´d like invest some money into a new NVidia graphics card, especially for Realtime Raytracing and baking.
    What would you suggest?

    (For example, is the extra cost of a RTX 2080 Ti vs a RTX 2080 Super justified?)

     
    Last edited: Jan 8, 2020
  41. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Depending on your scenes, the extra 3GB that comes with the 2080Ti is well worth it in my opinion
     
    guycalledfrank and Cascho01 like this.
  42. CFrosty

    CFrosty

    Joined:
    May 9, 2018
    Posts:
    8
    I must be missing something. Is there a way to use light probes with light baked prefabs? I've tried quite a few configurations and I am stumped.
     
  43. SquallLiu

    SquallLiu

    Joined:
    Jun 19, 2017
    Posts:
    32
    Hi Frank,

    Can we clear light probes only and stay light maps with Bakery?
    Normally we bake light maps once, and try to find a good placement for light probes.
    Which means we will bake light probes many times.
    Will Bakery clear previous light probes data if we bake a new group?

    Thanks.
     
  44. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    OK guys, I apologize for being quiet for some time, as I was on a holiday break. Back here now :)

    Are they basically dynamic (using light probes and all) or black?

    No, there is likely something with the model itself. Can investigate if you can send it to me.

    Ahh it is probably generated when I'm tricking Unity into producing the Lighting Data Asset for probes. Anyway - this file is useless.

    Separating is the way. Leaking can be mitigated by increasing resolution/padding (best advice I can give). Alternatively:
    - Use per-vertex lightmaps (see wiki). Impossible to get any leaking, but needs a customized shader + doesn't have denoising (but it's not that visible in outdoors).
    - Use a faceted normal map and Baked Normal Maps mode?! Weird idea, not really recommended, but can sort of work if you're sure you don't want to split vertices. Edges will still be blurry (resolution-dependent).

    Can be harmless. Slight UV inaccuracies are not a problem, but if you get odd results for these models, it's worth checking the layout.

    Causes can be:
    - Not enough disk space where the temp/output folder are located.
    - Project path/temp path/output folder having non-ASCII characters or some weird special characters. Some major cases like that were fixed (using UTF), some may remain.
    - Some non-standard write permissions set on the project folder or the existing hdr file being overwritten (read-only?). Although since some version Bakery started checking for these attributes and overriding them if needed (it turned out some version control systems can mark files as read-only).

    Setting Render Mode to Substractive should configure the light correctly.

    Correct - the problem is specific to the new 2019.3 UI (seems to be still in beta).

    This was recently fixed (for Unity >= 2018.4): https://github.com/guycalledfrank/bakery-csharp/commit/3cc75a8b679dc09091bc937a41aa89c0afe58e34

    (You can get github access and hot patches here: https://geom.io/bakery/wiki/index.php?title=Github_access)

    Long story short, models with more than 65k vertices were traditionally split into multiple chunks by Unity to allow using 16-bit index buffers; newer versions allowed using 32-bit buffers instead, with no splitting, but broke the unwrapping function; 2018.4 fixed it.
    I would still recommend setting index format to 16-bit on your model assets for performance reasons (both real-time rendering and unwrapping time).

    TBH, I'm no expert - still using my 1060. But more VRAM is always good.

    Not at the moment. It is an inherent limitation of the engine - probes are basically global and static for the whole scene. Unity doesn't allow dynamically combining different probe sets.

    Removing the lighting data asset from the scene should do it. Lightmaps are linked separately.

    Yes - probes are global. Light probe groups are only a hint for the engine - they are combined to a single grid before baking.

    Baking the lightmaps, then arranging probes and clicking "Render Light Probes" to test them sounds like a right workflow to me.
     
    keeponshading likes this.
  45. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Hi there,

    I'm looking into whether to switch to Bakery, as there's one bit of functionality I can't seem to achieve using the Progressive lightmapper.

    I have some "breakable" objects in my game. For example, a wall that looks normal until it "breaks", leaving behind kind of a crater/hole in the wall. In order for this to look good, both the original and broken models need to have their lighting baked. But what happens with the Progressive baker is that the "whole" wall obscures the broken wall, and so the broken wall gets no baked lighting.

    Is there anything available in Bakery to basically make one object ignore another when baking it's lighting, so that I can switch between two objects and have their lighting baked as though they were the only version of that object?

    Thanks.
     
  46. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Technically you can abuse LODs to do it, see this post: https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-65-released.536008/page-17#post-3697591
    First LOD will cast its shadow on the world and itself; second LOD will only shadow itself. Both will receive shadows from the world (same goes for bounces).
     
    dgoyette likes this.
  47. SquallLiu

    SquallLiu

    Joined:
    Jun 19, 2017
    Posts:
    32
    Hello Frank,

    We get inconsistent result of baking if we use Bakery Lightmapped Prefab component.

    The baking settings:


    And the inconsistent results (purple one is wrong):



    We bake the same prefab many times with the same settings.
    However, we get different results every time.
    No crashes and errors.
    Is there anything to care about when using Bakery Lightmapped Prefab?

    The baking flow:
    1. Clear previous results and caches before baking a new one.
    2. Attach Bakery Lightmapped Prefab to the prefab we want to bake and apply.
    3. Drag prefab into a new scene and bake it.
    4. Finish bake and use baked prefab in other scenes.

    (Update: Sometimes the results are still inconsistent without using Lightmapped Prefab component. Can not figure out the reason causes inconsistency.)


    Thanks,
    Squall
     
    Last edited: Jan 16, 2020
  48. marenin

    marenin

    Joined:
    Sep 22, 2019
    Posts:
    10
    First of all, realy great tool. Just wow! Many wow!

    Have a realy wierd question here.
    In our workflow we modified lightmaps with some sort of gameplay elements and use position and world normals data for this.

    Is there a way to somehow read the Bakery working files like "uvsmoothpos_Static_objects.lz4" ?
    (if data in there are usefull for this case of course)

    Will be neat to use information that Bakery already did, and not generated it again in external tool )
     
    guycalledfrank likes this.
  49. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Welcome back.

    There are some nice changes on scene level coming.

    https://docs.unity3d.com/2020.1/Documentation/Manual/light-probes-and-scene-loading.html
     
    guycalledfrank likes this.
  50. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,667
    Where is the purple coming from, is it in the same atlas? (are the any purple lights in the scene at all?)
    What version of Unity are you using?
    Are you baking the road in a separate scene and then put it to your city scene?
    Do you bake the city scene after it?

    Really weird. So it can happen by just baking the full city scene together with no prefab components?

    If you don't have anything really purple in the scene, I think it might be a similar bug I noticed some people having, where some color channels simply disappear leading to fully red/green/purple lightmaps. The cause is not tracked at the moment but seems to be linked to being at VRAM limit or using too many samples.

    Yes.

    Option 1:
    - In ftRenderLightmap.cs find global variable named compressedGBuffer and set it to false.
    - Bake.
    - Files will be DDS instead of LZ4 (beware: huge file sizes)

    Option 2:
    - Grab this file: https://drive.google.com/open?id=1K9m9QahcBVEGqPOWVOoKt2qRSP-wQG_c
    - Call
    lz4unpack uvsmoothpos_Static_objects.lz4 output.dds

    - Read output.dds

    To read DDS files you don't need special parsers. All you need to know is:
    - int height is at byte offset 12
    - int width is at byte offset 16
    - raw pixel array starts at byte offset 128
    - for uvpos there will be 4 floats per pixel; for uvnormal it will be 4 bytes.
    - normals are "encoded" using best-fit normals technique, therefore they have much higher precision than you might expect from 3 bytes; unpacking is simply normalize(n*2-1).

    You can find a super-duper simple way of reading DDS with BinaryReader in my ftUVGBufferGen.cs (the resolution is hardcoded to 1024 there though).

    Oh, finally!
     
    marenin and keeponshading like this.