Search Unity

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

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

  1. SevenPawn

    SevenPawn

    Joined:
    Jan 5, 2018
    Posts:
    1
    Hi, I'm trying to bake a scene using light map UVs created in Blender but when I use the UVs from Blender the scene fails to export, giving an Argument out of range exception.

    My control is a new scene that bakes just fine using Unity primitive objects and default bakery settings.
    Then, I create a cube in Blender, making sure to give it a second UV channel for light maps, and mark the cube as static to be included in the bake.
    This always results in an "Error Exporting Scene" box. Here's the error.

    Followed by:
    It's like Bakery can't find the UV channel to bake to when it comes from Blender originally.
    Further to this point, I can successfully bake the same asset into the scene just by checking Generate Lightmap UVs as true in the import settings. When I try to find why one should work and the other shouldn't they appear identical except for the minor differences in the lightmap UVs. In case it matters, I have experimented with increasing the margin in my own UV map to be more than the one generated by Unity and the problem persists with maps that come from Blender.



    Thanks for reading, I hope there's a simple fix I've missed!
     
  2. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    75
    You can't use L1 with Render Light Probes, you need to set it to Legacy, that'll solve your error. L1 requires actually baking the scene for the probes to render.

    Unrelated to that issue, the "Bake probes per sector" doesn't seem to work. Subsequent scene bakes show this and aren't capturing.

    upload_2023-6-20_18-56-59.png
     
  3. rtx89

    rtx89

    Joined:
    Jul 12, 2020
    Posts:
    13
    This is amazing, thanks a lot for this Mr. F!
     
    guycalledfrank likes this.
  4. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    75
    So, I think I've run into an issue with this, at least as far as my setup is concerned. It's not working and I suspect it's because when baking sectors, I disable all sectors except for the one being baked so that the lighting and objects don't interfere with each other. Unfortunately this seems to be breaking the sector light probe baking.

    Should this work? Would it be possible to make it work?

    Moving the location of the probes isn't viable because lots of objects have probes on themselves which obviously couldn't work in that scenario.

    So an option to initialise "disabled" probe groups I guess?
     
  5. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    84
    I'm getting this error when i try to bake the light probes with bakery
     

    Attached Files:

  6. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    133
    Sorry, couldn't find any definitive information on it.
    Can I use Bakery on a project to bake all the lighting then share that project with someone that does not have Bakery?
    I'm thinking specifically on creating a library of environment assets to sell on the Asset Store.
    I'd use Bakery on a sample scene to show off the assets in the best light, but of course Bakery wouldn't be included with the asset.
    I would need to include some Bakery specific shaders for the lighting to work correctly in the SRPs though, right?
     
  7. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,669
    I wrote to Eugene (the author of MLP), and I think we'll work it out and make it compatible :)

    Compressed volumes use BC6H by default which is not widely supported on mobile webgl: https://caniuse.com/mdn-api_ext_texture_compression_bptc

    I don't know what format Unity compress the volumes on WebGL, but due to Unity's tendency to go with the lowest common denominator, I suspect it just makes the HDR volume LDR instead.

    Does it work without compression? RGBA16f should be more or less widely supported even on WebGL 1.

    Seems like some internal Unity bug. What's your Unity version? Seems related:
    https://forum.unity.com/threads/res...ource-1048576-max-is-1048575-on-linux.993201/

    You don't have to actually - L1 light probes are rendererd along with lightmaps anyway.

    As for the cause of the issue, I might've found something related recently (with the help of davesmeathers) - turns out when I'm sorting objects by area, equal-area entities can get swapped randomly between bakes; I've added a fix for it that should ensure that consequent bakes of the same scene are always the same (you can get it via patcher/github for now).

    Same issue as above (in your case just disable "render light probes", because they are already rendered).
     
  8. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,669
    Ah, I think I answered your DM. (For others): seems like your ftGlobalStorage.asset got corrupted somehow. Deleting the asset will let Bakery regenerate it and fix the issue.

    I can't reproduce this, and your screenshot isn't showing the full stack trace, so I don't see where it's coming from :(
    Tried to render multiple sectors multiple times in my test scene.
    What steps lead your to this error?

    Objects from other sectors are not exported anyway, so you don't need to disable them yourself. They're approximated using the data "seen" from Capture Points, but if your sector doesn't have them, then it will completely ignore all surrounding objects.

    All scene lights are active, but if it's not a directional/sky light, it will be automatically ignored if its bounding box doesn't intersect sector's bounding box (it actually always happens on the lightmap group level, it's just none of your groups will ever extend beyond the sector in this case).

    I can also see why it doesn't work in your case. The way it works now:
    - A composite lighting data asset is initialized for all active light probe groups.
    - Light probe data is set for probes from the rendered sector.
    - Probe data is also copied here to the scene file:

    upload_2023-7-1_14-42-34.png

    - You render another sector:
    - A new lighting data asset is initialized. If you disabled previous light probe groups, they're no longer there.
    - Light probe data is set for probes from the rendered sector.
    - prevBakedProbes are merged with new data based on prevBakedProbePos. I.e. probe IDs can be shuffled around, but as long as their position is approximately identical, the merge will work.
    - Updated probe data is stored in the scene file.

    Thus:
    - You can bake separate sectors, and their probe values will merge with whatever previously baked.
    - You can increase or decrease probe count, and the merge will still work.
    - Moving probes will invalidate the merge (rebake needed).
    - Disabling/removing probes will invalidate the merge (their values will be effectively forgotten and require a rebake).

    My idea was that you don't disable light probe groups manually, therefore Unity will always create a full-scene probe grid. Bakery will still ignore objects from other sectors and only write probe values associated with this sector, so you shouldn't worry.

    There is one thing to improve though: currently sector probe rendering will still ask the lightmapper to calculate all colors for all probes and then discard unrelated probes later, meaning that sector probe rendering is slower than it should be, but I'll fix it soon :oops:

    It looks like it can't find any light probe groups in the scene. Do you... have any? Does it work with my example scenes?

    Yes: https://geom.io/bakery/wiki/index.p..._who_doesn.E2.80.99t_have_Bakery_installed.3F

    Only if you use special lighting modes like RNM/SH/MonoSH. If you bake it using standard lighting modes, then it'll work with any shader.

    BTW I'm OK with distributing my shaders/graphs freely (well, my URP graphs are already freely downloadable from the wiki).
     
  9. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi Frank,

    Unity 2021.3.24f1

    Posting here for others in case they want to follow along.

    I sent you the small example project with the lighting data issue.

    From what I can tell, one lighting data file is being shared across multiple scenes. Which is causing the bakery textures to get confused? :oops: .. it's just a guess. I hope you can figure it out. :rolleyes::rolleyes:
    upload_2023-7-1_13-38-31.png

    Also if there is a suggested version of Unity to use, please let us know.

    Thanks again for your help !
     
    guycalledfrank likes this.
  10. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    75
    2019.4.31f (as it's for VRChat).

    So, I just tried this. The bake would take less than a minute when baking one of the small areas with just that sector enabled. So far it's been going for around 5 minutes and is only at 12%. It seems to be spending all it's time rendering area lights for the other sectors.

    The main reason I wanted to disable all the "not in use" sectors (other than the fact the editor is borderline unusable with them all enabled which in turn slows down everything else) is because light tends to bleed over from one sector to another.

    They're packed together as close as possible due to trying to avoid the "distance from 0" jitter issues.

    We can't use different scenes in VRChat so everything needs to exist within the same "space" hence why this is such an issue. And as it's also for Quest as well as PC, "distance from 0" becomes doubly an issue due to the Quest's terrible depth buffer accuracy.

    But yeah, as it stands, it looks like baking one sector with all the rest enabled is going to be almost as slow as baking the entire world in one go (with the same caveats of light bleed) unfortunately. Not really sure what to do there if I can't disable sectors.
     
  11. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    75
    An issue I've had for a long time (which I suspect is a Unity bug, but I can't try other versions with this project - I'm using 2019.4.31f) is after every light bake, there's a chance that the hierarchy window will become a LOT slower. The double issue is that this is cumulative to the point where after 2 or 3 bakes, the hierarchy is completely unusable. Even so much as mousing over it will result in the entire Unity window becoming unresponsive for 10 seconds or so.

    Has anyone else experienced this or have any idea why it happens?
     
  12. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi Frank,

    I have 3 questions for you.

    #1. In regards to lightmap baking time, how important is VRAM to Bakery? In your opinion, does Bakery benefit from upgrading a 3060 to a 4060 for a laptop graphics card? This guy here is talking in relation to games, but I imagine it's the same for development?:rolleyes:


    #2. I brought it up in the past, but maybe you missed it. Is this error normal?
    upload_2023-7-9_14-11-42.png

    #3. I can't log into the Bakery github anymore. I sent you a DM. Can you please check the screenshot?

    Thanks for your help!
     
    Last edited: Jul 10, 2023
  13. whoopgame

    whoopgame

    Joined:
    Jul 3, 2022
    Posts:
    9
    Hi! Is there a way to separate Metallic/Gloss and Specular/Gloss textures for Bakery Standard and Bakery Specular respectively? I've tried messing around with Standard shader source code, editing and replacing cginc-s, modified Bakery shader inspector script, however I had no luck.

    And another issue - how can I move Volumes in runtime? Seems like I have to reassign volume to the material every time I move the volume. Since I move it every frame, it's not very good performance-wise, when there are quite a lot of objects using that volume. Am I missing something?
    For the context - it's an ar app, camera is controlled by ar api, so instead of moving the camera we move the object itself

    UPD

    For the first issue - I've found your custom surface shader with volumes support, could modify it for our needs. Is there any way to add baked specular for that shader?

    For the second - when I move volume, I do UpdateBounds in BakeryVolume class, and set _VolumeMin property in shader afterwards. Is this a correct way to move volumes in runtime? Looks wise it looks correct, however I'm not sure this is the best way to do it.
     
    Last edited: Jul 8, 2023
  14. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    84
    Is it normal for the GI not to work with unlit shaders? I have already did some bake tests using the same colors and textures, and it seems like the GI doesn't work, but the lighting, shadows, and ambient occlusion do, With lit shaders everything works fine, I'm using Shader Graph.
     

    Attached Files:

  15. Anvarito

    Anvarito

    Joined:
    Sep 13, 2017
    Posts:
    8
    Can you tell me how to set some very low settings to bake quickly and see the preliminary result? I did this with standard baking in unity and waited just a minute, and with this plugin I waited 30 minutes, and unity said there wasn't enough memory. I would like to understand where you can reduce)
     
  16. scrup

    scrup

    Joined:
    Dec 13, 2021
    Posts:
    8
    Just trying to import it into my new project using 2022.3.4LTS and it is not wanting to cooperate. Been sitting at this screen for 45 minutes now. Any suggestions on how to get this to import in a reasonable amount of time?
     

    Attached Files:

  17. scrup

    scrup

    Joined:
    Dec 13, 2021
    Posts:
    8
    Try the quickstart instructions here and see how it works - https://geom.io/bakery/wiki/index.php?title=Manual#Quickstart
     
  18. Anvarito

    Anvarito

    Joined:
    Sep 13, 2017
    Posts:
    8
    I mean, in the standard settings of the lightmaper, I could set the values so low that the baking would take place in 1 minute, this is necessary for the preview.And in this asset, I did not understand how to set everything very low, and yes, I tried this quick start - I baked for 40 minutes after which unity fell and a message came out that there was not enough memory:(
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Sorry if this has been asked, since i can't find it using thread search.
    I have some issue with Bakery in URP on 2022.3.4, i'm using the example scenes as a test here.
    Issue #1
    Lightmap are missing when going into play mode
    upload_2023-7-12_20-32-25.png
    upload_2023-7-12_20-33-6.png
    Issue #2
    Sometimes the lightmap RGBM encoding seems incorrect
    upload_2023-7-12_20-35-41.png
    upload_2023-7-12_20-36-4.png

    is anyone know any fix for those issue?
     
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,669
    Added OpenImageDenoise 2.0 support to Bakery:



    You can get it via github/patcher for now :)
    Seems like the best of both worlds: it's now as fast as OptiX 6/7 (running fully on the GPU), while not being driver-dependent and producing the exact same results as OIDN1 on all hardware:
    https://twitter.com/guycalledfrank/status/1675946606397386766/

    Note: seems like OIDN2's CUDA runtime is only working on Volta/Turing/Ampere+ GPUs (i.e. 16XX or 20XX+).

    Just added unused probe skipping when rendering sector-only probes. Can you patch and try it again? Should be much faster.

    Haven't seen this before. Can you profile the editor (with the profiler)? It should shed some light on it.

    More VRAM = larger worlds to bake in one go (without Sectors, etc). If your scenes already fit in your VRAM, then it won't change much.

    The "name mismatch" warning is something that started happening in Unity 2020+. So far I didn't notice it actually affecting anything functionally.

    Shouldn't be a big problem. How would I do it:
    - Copy the shader, rename it, rename its title as well (top line in the file)
    - Bakery shaders use a custom scripted inspector (based on the Standard shader inpsector), you can see it defined as
    CustomEditor "BakeryShaderGUI"

    in the shader code. You can change it as you wish, but for the sake of simplicity, just remove this line.

    - Add e.g. a GlossMap somewhere around similar lines for other maps:
    _GlossTex("Gloss", 2D) = "white" {}

    It's now visible in the default shader inspector:

    upload_2023-7-12_16-40-23.png

    - The actual shader logic is inside Bakery.cginc. Make a copy of it (e.g. Bakery2.cginc) and replace the path in your shader:

    upload_2023-7-12_16-43-59.png

    - In your Bakery2.cginc copy, look for FRAGMENT_SETUP. This is a standard included Unity macro that fills up surface properties. Right after this line you can replace default values with your own, e.g.

    upload_2023-7-12_16-55-45.png

    And just with a couple of lines:

    upload_2023-7-12_16-56-5.png

    Take a look at my URP/HDRP graphs. BakeryDecodeLightmap.hlsl has some neatly isolated methods for every feature, e.g. DirectionalSpecular_float(), BakerySpecSH_float()...

    Yeah, sounds correct :)

    Depends on how the unlit shader is implemented. Either it has a Meta Pass, supplying albedo/emissive data to lightmappers, or it has common property names, such as _MainTex/_BaseMap/_BaseColorMap/_Color... I suspect in your case there is no Meta Pass explicitly defined, and the color is not "_Color".
    See: https://geom.io/bakery/wiki/index.php?title=Manual#Material_compatibility

    Depends on your scene.

    For Texels Per Unit, as I mentioned in the docs:


    • [*]Large outdoor area (a city): 1 - 5
      [*]Medium outdoor area (a few alleys): 10-20
      [*]High quality interior: 100
    Then you also don't need 5 bounces for a quick test. In fact, I often use just 2 bounces in many production scenes :)

    If you have a Skylight, reduce its samples to 16 (instead of default 32), it will be enough for most outdoor scenes.

    If you have many painted terrain trees, note that Unity lightmappers just ignore them, while Bakery doesn't. You can disable them: https://geom.io/bakery/wiki/index.php?title=Manual#Export_terrain_trees

    Never seen such behaviour before. The shader is not very complex. Possibly some bug in the Unity shader variant compilation pipepline? https://forum.unity.com/threads/build-time-taking-almost-a-day-urp.1133605/

    upload_2023-7-12_17-24-58.png

    Not sure, but it might be the culprit. Also maybe try terminating the editor and checking Editor.log for anything unusual.

    Sounds like you have a very large world + default Texels value (20)?

    :( did you try it on any earlier versions before? I didn't test it on 2022.3.x yet, only on 2022.2 (seemed to work)
     
    Last edited: Jul 12, 2023
    whoopgame likes this.
  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @guycalledfrank i haven't sadly
    Edit : Also i notice the missing lightmap always happened on object that use URP Lit Shaders, but yours shader just fine.
    Also any information about the incorrect RGBM encoding?
     
    Last edited: Jul 12, 2023
  22. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Yeah, on 1080 it throws 505 error with no other details. Any possibility to make it work together?
     
  23. Enverex

    Enverex

    Joined:
    Jul 6, 2019
    Posts:
    75
    The massive several second long spikes are me mousing over the hierarchy and the UI basically stopping. This happened after the second Sector bake.



    Possibly more detail:

     
  24. rtx89

    rtx89

    Joined:
    Jul 12, 2020
    Posts:
    13
    Hey Mr. F,

    Thanks again for the recent light probe in sectors change. Such an amazing feature!

    I've had some issues getting github access for RTPreview. I've dm'd you on discord with my invoice number and github username.

    I'm experiencing an issue with RTPreview, where objects get weird broken textures/UVs on them. I attach a screenshot of what RTPreview shows, versus what I see in Baked Lightmap view after baking. The real scene looks fine too, the only place I see this issue is in RTPreview. I'm using HDRP in 2019.3.15.

    I've also noticed another issue since the probes in sectors patch. If I have two sectors with lightmap groups inside, bake one sector, and then bake the other sector without a light probe group inside, or 'bake probes with sectors' checked, bakery will bake black lightmaps for groups in the first sector and put them into the new sector's directory. They are fully black and do not get applied to objects in the scene. Example here: https://media.discordapp.net/attachments/648434699785601027/1127645137900671027/image.png - 'exterior232', 'interior232', and 'walls232' are the only lightmap groups in the 'new inner test' sector, and all of the other groups in the screenshot are from other sectors. It doesn't take much time baking them, but it wastes a lot of time denoising and composing these wasted maps.

    Cheers
    preview vs baked lightmap view.jpg
     
    Last edited: Jul 19, 2023
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @guycalledfrank i found what causing the inccorect RGBM encoding, it's the baked lightmap settings. Somehow they are set to Default Texture Type. Manually set them as Lightmap fixed this issue, this also randomly occurred with ShadowMask and DirectionalLightmap somehow both also got set as Default Texture Type.
    upload_2023-7-14_2-30-51.png

    Oh and also i'm getting Error 902 using OIDN2 i'm using 1070
     
    guycalledfrank likes this.
  26. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Ok good to know. For now the scenes are able to bake in 1 go (if we ignore the lightmap errors I'm having at the moment):D

    Ok. I'll report back after I continue to do more tests on the scene.

    Thanks!


     
    guycalledfrank likes this.
  27. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    Hi @guycalledfrank

    I would like to ask you a question about lighting technology. Can you help me?

    I have a big scene include:

    (1) Rendered the Static building model using Bakery's full lighting(added light probes).

    (2) I rendered the non static Stage model using realtime light, So I didn't set it to static, I didn't use bakery to render its Lightmap. Then, I used realtime light and created some dynamic lighting effects for the stage. It works normally in the editor, but exporting APK to Android doesn't display all the realtime light,What should I do?Thank you.


    Some of my thoughts:
    (1) Can't I use both Static mesh of Baked light and Non Static mesh of Realtime light in an Unity scene?
    (2) I have thought about using mixed light for all static meshes( building and stage ),For example, bakery's shadowmask or Subtractive, But lighting map files will increase significantly.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      409.7 KB
      Views:
      65
  28. rtx89

    rtx89

    Joined:
    Jul 12, 2020
    Posts:
    13
    It sounds like you should not use "Full Lighting" if you want some lights to be realtime.

    Switch 'Render mode' to 'Indirect', baked direct and indirect lights will still render correctly.
     
    trojant likes this.
  29. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    I would say its more about android build setup, if it works in editor, check Pixel light count in your Quality settings.
    It is surely possible to have baked (static) and dynamic (non-static) meshes inside one scene, and it does not matter what Render mode you use.
     
    guycalledfrank and trojant like this.
  30. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    I suspect that my Unity engineering project has disabled realtime light or mixed light from somewhere? Because I have recreated a project and used Bakery's full lighting to export APK to Android phones, these tests show realtime light and mixed light.
     
  31. rtx89

    rtx89

    Joined:
    Jul 12, 2020
    Posts:
    13
    I'm not sure exactly what happens but I remember in the past I had an issue with Full Lighting disabling unity lights after a bake which I did not want. Switching to indirect render mode + enabling 'direct + indirect' on the light source fixed it for me, but this might be another issue.
     
  32. smash-ter

    smash-ter

    Joined:
    Sep 6, 2020
    Posts:
    22
    I'm honestly surprised that Bakery hasn't implemented Radeon's HIP or possibly add the new HIPRT, though it might be generic CUDA porting from what you're describing here. it would help to at least expand compatibility for those who do not have an Nvidia GPU laying around or as a secondary GPU. Even integrating Intel's oneAPI would be an added bonus for those who have Arc cards
     
  33. wechat_os_Qy059rNpXEz8vip3kkFUJiFGA

    wechat_os_Qy059rNpXEz8vip3kkFUJiFGA

    Joined:
    Feb 28, 2022
    Posts:
    1
    Hi, I turned up the baking parameters, and the baking diagram is wrong. It turns blue. The parameters of low baking look normal. How can I solve this problem? This error can also occur when baking in advanced mode.
     

    Attached Files:

  34. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Is it possible that MonoSH has some weird attenuation? In this scene there is green ground and 2 emissive spheres, with normal mode the scene looks as expected but with monoSH it looks clamped

    upload_2023-7-19_14-34-33.png upload_2023-7-19_14-38-36.png
     
  35. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    The problem has been resolved. The quality settings file is damaged, and I have replaced it with a new one.
     
    guycalledfrank and rtx89 like this.
  36. ssdkongkong

    ssdkongkong

    Joined:
    Jul 21, 2023
    Posts:
    2
    All lightmap baked in my current URP project will have a purple color, regardless of the color of the light.(Just like every material become the error purple while baking).Meanwhile there is no such situation of lightmap turning purple in a new project.
    what may have caused this problem?
    ERROR.png
    (looks like error purple)
     
  37. ssdkongkong

    ssdkongkong

    Joined:
    Jul 21, 2023
    Posts:
    2
    project with issue.png new project.png
    these two scene are baked in the same render setting and a single bakery directional light.

    PurpleLightmapProjectConsole.png
    (console of the Purple lightmap project)
    The other project don't have these eight yellow warning after baking.
     
  38. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi Frank

    Can you help with 2 questions regarding Light Meshes?:rolleyes:

    1. When the light mesh is close to another object (the ground) , there's white\black artifacts in the light map.
    2. The custom light mesh casts self shadows even when I disable the self shadow tick.

    I tried playing around with settings, but can't seem to figure it out.

    Do you have any tips \ advice?:oops:

    I DM'ed you a link to the project.

    On a side note: The bug I was having with the corrupted lightmaps, ever since I updated the bakery files from github, they seem to have gone away. crossing fingers that was the solution.

    Thanks for your help
     

    Attached Files:

    Last edited: Jul 23, 2023
  39. OttoCorrect

    OttoCorrect

    Joined:
    Apr 4, 2014
    Posts:
    5
    Hi Frank,

    I'm trying to figure out what I'm doing wrong here with light probes. Unity 2022.3.4f1, Android, URP. Subtractive.

    The bake on left is with Bakery, right is with the Lighting window. I was just doing this for testing but the dynamic cubes in the shadowed area are very bright in the Bakery version vs. Unity.

    Any suggestions? It seems to me like the light probes are being affected by the directional light even though they should only be in shadow. 2023-07-23_15-24-12.png
     
  40. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,669
    That's weird... these example scene lightmaps have Lightmap type by default. Did you rebake them? I'm not sure how they ended up being Default. Could it be that you somehow selected all textures in the project and applied the same settings to them? Are new lightmaps in newly baked scenes come as Lightmap or Default?

    Yeah unfortunately it doesn't support 10XX GPUs in CUDA mode. Apart from CUDA it supports SYCL which might work, but still slower, because I'd have to copy data back and forth to CUDA; HIP, which is AMD (could work like SYCL if you have 2 GPUs) and CPU, but then you can just use OIDN1 on the CPU. So for now I only included the CUDA version, as it's the only one offering significant benefits in this case.

    Just added OIDN2 testing to the integrated benchmark:

    upload_2023-7-24_17-36-41.png

    As usual, after running the benchmark once, it'll remember compatibility values and notify you when trying to use an incompatible denoiser before baking.

    From this capture I only see the time it takes to redraw the scene and the profiler itself... I'm not sure how to relate it to anything I have control over. Seems like some deep editor bug.

    Replied!

    Something is wrong with the UVs... while lightmaps look OK, the GI is affected by the albedo as seen in RTPreview.
    I think what happened is that I removed a special atlas-flipping fix for HDRP because HDRP itself stopped requiring it in newer versions. Looks like I'll have to add some version branching for HDRP.

    Quick check: in ftUVGBufferGen.cs, there is a line:

    Shader.SetGlobalVector("unity_LightmapST", scaleOffset);//(isHDRP) ? scaleOffsetFlipped : scaleOffset);


    Try replacing it with:

    Shader.SetGlobalVector("unity_LightmapST", isHDRP ? scaleOffsetFlipped : scaleOffset);


    If it's the only reason, I'll make a version-based switch.

    Since it's build-only, it's likely related to shader/mesh stripping: https://geom.io/bakery/wiki/index.p...iated_at_runtime_in_a_build_have_no_lightmaps

    Not a problem at all. But Unity may not realize that some objects are lightmapped if the scene is not open, because external lightmaps are not referenced by the lighting data asset; thus removing lightmap-related data in the build.

    Standard real-time Unity lights (without any Bakery components) will act as usual after baking, even in Full Lighting.

    Good point - could be related too.

    ...oh :)

    Time... constraints... :eek:
    I should look into it seriously though. Now that I have a laptop with an integrated AMD GPU, I can maybe test on it (it's not too bad).

    My suspicion is that you're using an old version of Bakery where Optix 7 denoiser integration was sort of bugged and could produce weird colors. Check if it happens:
    - With any other denoiser.
    - With latest github patches (or even just the latest Asset Store version - it has the fix).

    The attenuation itself is the same... what's different is how normals and lighting rays interact with each other. In a non-directional mode, the normal is taken into account when tracing the rays - they are emitted over the normal-oriented hemisphere, with cosine weighting baked into ray probability (basically dot(n,l) already in the lightmap). In the (Mono)SH mode, rays are traced in all directions and accumulated to 4 different outputs (overall lighting, X lighting, Y, Z). These values are then combined with surface normals in the shader, but because we don't have individual rays anymore, the resulting weighted sum is more approximate and has some deviations (like the ones on your screenshot). It is possible to implement some weighting that counteracts it...
    But, the first to try is to disable non-linear SH sampling and compare; I've noticed it affecting such gradients while testing. If you're using standard RP, it's the "Non-linear SH" checkbox. If you're on URP/HDRP, I'll send a modified graph.

    (BTW, you can fix texture blockiness by enabling "High quality direction" in Project Settings -> Bakery or just setting Compression = High Quality on the L1 texture assets by hand).

    Weird! Things to check:
    - Old Bakery version + Optix 7? (as previously mentioned) What is your version? (shows on a tooltip if you hover your mouse over the blue text on top of the window)
    - Does the issue come up with Denoise disabled at all?
    - Lights having extreme intensity/indirect intensity? (>10000?)

    OK, actually it looks like pink GI, meaning your Meta Pass shader is writing pink: https://docs.unity3d.com/Manual/MetaPass.html

    Are you using a custom shader? Does it show any compilation errors if you select it? Does it have a "Meta" pass?

    Replied to your DM, copying here, just in case:

    1. When setting self-shadow you forgot to set "Samples Near" to anything > 0 (16 would be OK).
    The way it works (old dev pic):

    upload_2023-7-24_19-35-42.png

    When "samples near" is 0 or "self-shadow" is disabled, you have the "just points" result.

    Actually there is a confusing thing with the UI when you disable self-shadow, and it resets "samples near" to 0... it should keep the old value by default.

    I've just fixed that UI issue.

    2. The shadow thing is not actually a shadow :) It's just a little un-illuminated gap between two area lights, because their thin shape is not directly visible below. Adding a bit of thickness to the mesh will light up this gap.

    You need to enable Occlusion Probes: https://geom.io/bakery/wiki/index.php?title=Manual#Occlusion_probes
     
    Last edited: Jul 24, 2023
  41. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Those were how i got them imported from the package i didn't change anything on the sample assets . I only bake the scene that require to be baked specifically, but sometimes even a new bake the lightmap also imported as default texture which is kinda random idk why.
     
  42. OttoCorrect

    OttoCorrect

    Joined:
    Apr 4, 2014
    Posts:
    5
  43. JohanL

    JohanL

    Joined:
    Apr 15, 2013
    Posts:
    20
    I have been using Bakery for all of my projects, and I am very happy with the results for every single on of them, I love everything about bakery!

    I would like to integrate Bakery into my current HDRP project, but I am having some trouble getting consistent results.

    The Bakery manual does not provide much information on how to set up Bakery for HDRP. I have tried updating the Skybox Probe multiple times, but it rarely works. Most of the time, I get the following error: Importer(TextureImporter) generated inconsistent result for asset(guid:13f1d46ad26fded42ab679c5e5d9ae98).

    When I have managed to correctly bake an HDRI and change the settings to what the manual specifies (exposure down from 11 to 1), I get wildly different rendering results to the built-in renderer, and I feel like its alot harder (impossible?) to make it work with the PBR-workflow in HDRP.

    I am wondering if I am missing something important, or if Bakery is simply not meant to be used with the HDRP Procedural Physical sky and the physically correct workflow (or whatever Unity calls it)?

    upload_2023-7-25_19-43-20.jpeg
     
    guycalledfrank likes this.
  44. smash-ter

    smash-ter

    Joined:
    Sep 6, 2020
    Posts:
    22
    Wish you luck on that.
     
    guycalledfrank likes this.
  45. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Ahhh ok ok ! Thanks for the clarification. I didn't notice the "disable self-shadow = auto set to 0" .. but good thing you caught it. I wouldn't have noticed. :)
     
    guycalledfrank likes this.
  46. alex123456

    alex123456

    Joined:
    Mar 6, 2014
    Posts:
    4
    Hi, is there a way to add normal map just for the meta pass, and not the runtime material?
    I've tried everything I could but apparently Unity meta pass completely ignore any attempt of adding a normal map, neither could I make it work with bakery meta pass. We are building for mobile VR and the only way so far is to change the shader before baking to a shader with normal map and then back to one without, for performance reasons. The final shader on the device should be just the albedo and lightmap combined, with no extra calculation.
    Any feedback is appreciated since this is the biggest reason we are trying to switch to Bakery.
    Thanks
     
  47. alex123456

    alex123456

    Joined:
    Mar 6, 2014
    Posts:
    4
    Further to the issue, every attempt I had of making the bakery meta pass work results in black. Even with the included examples of Baked_Alpha_meta and Baked_Normal_Maps_meta. By default they are missing the location of BakeryMetaPass file, so they render magenta. Correcting the location results in black always.

    I included the result using the Baked_Normal_Maps_meta and another switching it to standard shader before baking.
     

    Attached Files:

    guycalledfrank likes this.
  48. alex123456

    alex123456

    Joined:
    Mar 6, 2014
    Posts:
    4
    So, I found a solution for my case that actually works better than meta pass. On the shader I put this around the normal:
    Code (CSharp):
    1.                 #if SHADER_API_MOBILE
    2.                 #else
    3.                     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
    4.                 #endif
    That way the mobile shader doesn't receive the normal map instructions but Bakery still does. It seems to work only for normals though. If I set the mobile albedo to red and else to green, it will bake the color based on whatever build settings I use at the moment. If I'm switched to android, it will bake red. If I switch to windows it will bake green.

    But that way at least I don't have to set a whole meta pass just for the normal, which so far doesn't work with meta in any way I could try either way.
     
    guycalledfrank likes this.
  49. OttoCorrect

    OttoCorrect

    Joined:
    Apr 4, 2014
    Posts:
    5
    @guycalledfrank Just wanted to reach out and see if you had any other suggestions. Thank you!

     
  50. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi @guycalledfrank

    I got 2 more questions: :oops:

    #1 -- I'm using editor scripts to customize my lights. (Almost 100ish) ..

    Every time I make a change to the light values I have to go back and also press this button for each bakery light.
    upload_2023-8-2_13-33-14.png
    Can you please tell me how I can access this method publicly? I'd like to call the method from my own editor scripts.


    #2 -- Is there a way to stop the bake before Bakery starts up the Progress[%%] pop up window? There are times I forgot to make changes and I want to cancel the bake, but have to wait until the Progress[%%] pop up window appears. This isn't ideal because the import sometimes takes 40+ minutes.

    How to cancel Bakery before we get here.
    upload_2023-8-5_15-28-46.png

    Thanks for the help as always!:)
     
    Last edited: Aug 5, 2023