Search Unity

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

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

  1. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Also, make sure to enable the bicubic interpolation mod for Unity shaders in Bakery. It will help A LOT with that.

    It's not compatible with OpenGL or Vulkan though.
     
  2. iLeetZero

    iLeetZero

    Joined:
    Jan 11, 2021
    Posts:
    3
    Yeah I'm looking forward to the antialiasing feature. Rendering at higher size and reducing would have to do for now. It truly would be nice to have some post-processing blur application though.
     
  3. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Does anyone here knows how to add Area Lights to the bake with Bakery?

    Regards,
    Carlos
     
  4. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    Yeah that would explain some behaviors lately...
    Thanks for the fixes, and the supersampling thingy on shadows !
     
    guycalledfrank likes this.
  5. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    guycalledfrank likes this.
  6. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    It's not compatible with SRP's too, right ?
    Would it be technically possible in custom shaders or is there some hardcoded limitation ?
     
  7. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Thank you atomicjoe! You should get paid by the asset creator!:)

    Regards,
    Carlos
     
    guycalledfrank and atomicjoe like this.
  8. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Nope, doesn't work with SRP.
    It's technically possible in custom shaders: I have integrated it on my custom shaders.
    However, the problem is the lightmapping part of the code in Unity's shaders is not easily modifiable:
    On surface shaders (built-in pipeline) it's not accessible at all (although you can hack that) and on SRP, I'm pretty sure there is no way to customize it in the shader graphs. Same for Amplify Shaders.
    On full custom shaders (vertex + pixel shader) you can make it no problem.
    I think that maybe with Better Shaders you could do that, but it would require to code a new template and I don't know how much work it means.
    Either way, you will need a pretty good shader coding level to do that. It's quite involved.
    Also, keep in mind the bicubic filtering in Bakery doesn't work out of the box for OpenGL and Vulkan because Unity's HLSL to GLSL translator has some shortcomings, so there is no way to get the size of the lightmap texture in GLSL.
    That means no support for Android, Oculus, MacOS and Switch. (I'm not sure about iOS, since it uses Metal)
    But if you hardcode the size of the lightmap textures beforehand, you can make it work on those platforms too. (you force all your lightmaps to, say, 4096x4096 and hardcode that size in the shader code)
     
    Noors84 and guycalledfrank like this.
  9. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi,

    booth GPU´s are baking but there are crashes with timing errors.
    On old benchmarks where i used 2 GPU´s it was also slower than using one.

    Is there a way to disable one with Bakery without chaning sytem settings?

    1.JPG
     
  10. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Any ideas what to do here?
    It pon 2x3090´s with 24GB RAM.

    1.JPG



    upload_2021-9-3_14-53-34.png
     
  11. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    This did not help.

    The Bakery preview also does not work and goess up like this on scene export...

    2.JPG
     
  13. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Disclaimer: I'm not the author, just a friendly fellow user.

    Weird, because that's exactly the issue there: windows killed the graphics driver because it took too long to respond.
    It may be an issue with SLI though. Have you tried rendering the same scene with only 1 card enabled in windows? (just to see if it renders or just keeps crashing)

    Maybe your scene is just massive or has tons of large textures?
    Does this happen with the included Bakery sample scenes too or is this happening just on this specific scene of yours?
     
    guycalledfrank likes this.
  14. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    After 4h we found out that it must be some scene dependent thing.
    Created an new scene added my prefab again and it baked again.

    Now it runs fine and uses 27GB RAM and 10GB VRAM.
    But i think GPU0 here is slowing down a little.
    Is there a way to deactivate it?

    22.JPG

    Thanks for the help.
     
    Last edited: Sep 4, 2021
  15. thusky

    thusky

    Joined:
    Nov 28, 2017
    Posts:
    6
    Hey there! I was curious to know about the status of potential AMD support? I saw the question has been asked a year ago or so and figured it'd be a good time to check it out!
     
  16. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    To see the actual use of a GPU in the task manager under Bakery, you have to select "COMPUTE" or "CUDA" instead of "3D".
    Bakery uses Nvidia Optix library, which is made by Nvidia and specifically developped to take advantage of as many Nvidia GPUs as possible, so it should run perfectly.
     
  17. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Unity's denoiser is apparently something like a bilaterial blur. It's a (I assume) gaussian blur than stops at edges.
    The problem with such approach is that blurring heavy noise can still look just like "blurry noise".
    Bakery uses OptiX and OpenImageDenoise that work very differently. These are neural networks trained to get rid of noise, recovering something that looks like a noise-free image. They don't blur. They don't have a slider. Their purpose is not blurring.

    Shadow spread basically controls physical light size. The larger the light, the blurrier are the shadows. This is because small light sources can be fully occluded easily, resulting in sharp lit/shadowed transition, while large light source is partially visible from many different points, resulting in a wide penumbra:




    Large penumbra requires more rays to be traced from each surface to get its gradient accurate:

    upload_2021-9-5_15-37-36.png


    Hence, if we don't use enough rays, we get the noise and we can get rid of it using a denoiser. Denoiser's job is just to make it look as we had a LOT of rays without actually tracing that many rays.
    Blurring can approximate the denoising result in some cases, but overall, it's a hack. There is no uniform blurring in the lighting equation. As Bakery started as a physically-correct renderer, I preferred the less biased neural net based denoisers to spatial blurring.

    "Blockiness present": Try the latest patch where I just added the "Anti-alias" option on the directional light. Should help.

    Why? Uniform blur is a pretty arbitrary post-processing effect.

    Supersampling and denoising makes sense to me, blurring doesn't.
     
    hippocoder likes this.
  18. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Because, as artists, sometimes we need more control than what reality offers.
    Just like Pixar uses lots of negative lights to more acurately shape the mood of a scene, blurring a lightmap offers you more creative freedom to convey a feeling.
     
  19. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Also, negative lighting would be AWESOME, but I don't even know if Optix supports that.
     
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,672
    Kinda possible to get it for color lightmaps in a hacky way, but very tricky for shadowmasks, as there is not way for shadergraphs to modify lighting code. In BetterLit/BetterShaders I got it working, except shadowmask is broken there in HDRP.
    The main limitation is that the lightmap reading code needs to be changed, ans it tends to be deep in the ever-changing package code. Standard pipeline shaders didn't change much in a few years, so my patcher still works.
    For color lightmaps in HDRP it can be done in an almost non-hacky way, as its shadergraphs allow overriding GI.

    It's available in the patch, for directional lights at least, you can try it now.

    Yes. I should probably move it to Project Settings. But currently you can go to ftRenderLightmap.cs and find this line:

    const uint deviceMask = 0xFFFFFFFF;


    This mask defines which GPUs are used. If you open .ftracelog.txt, you can see which GPU has which ID, e.g.

    Device 0: GeForce GTX 1060 6GB (ON)


    You can use only GPU 0 by setting deviceMask = 1 or GPU 1 by setting deviceMask = 2 ("0xFFFFFFFF" means "all". GPU 2 would be deviceMask=4, GPU 3 would be deviceMask=8, etc).

    .ftracelog will mention used GPUs as "(ON)" and unused as "(OFF)".

    You've hit TDR during scene export: https://docs.microsoft.com/en-us/windows-hardware/drivers/display/timeout-detection-and-recovery

    This is usually caused by having some object marked as lightmapped, while not having proper lightmapping UVs. When previously debugging cases like this I found it to be caused by objects that had some weird garbage in their UV1 that looked like every triangle occupied the whole layout. Simply rasterizing many thousnads 4096x4096 triangles took GPU too long and this happened.

    UV overlap warnings in the console should give you some clue. You can enable the UV validation checkbox so it'll stop the bake after printing names of invalid models.

    Not currently planned unfortunately:(

    Persoanlly I feel that a lot of these "convey a feeling" cases were mostly caused by not being able to bruteforce a "proper" solution, platform limitations and artists not understanding how lighting works IRL. Now we can trace almost unbiased GI without needing to hack around it.
    Mobile platforms may require intensity hacks because it's expensive to run additional post-processing and Unity doesn't know how to patch tonemapping directly into material shaders.
    But blurring shadows... this gives me 2002 flashbacks from the times when dev PCs where very slow and many inhouse lightmappers didn't have GI, so they had to hack it with many colored lights and blurred shadows... and understandably it doesn't look very good in 2021.

    Why? What for? :D
    The only case of negative light usages I know is imitating "AO" from dynamic objects in deferred renderers where many unshadowed lights are cheap.
    OptiX is not a problem here; it's not a renderer, it just gives a fast hw-accelerated way to trace rays. The way Bakery uses it and mixes colors is up to Bakery. OptiX itself is relatively low-level, it doesn't know about "lighting". You can technically even use it for audio propagation.

    atomicjoe, if for some reason you're wishing to try doing a full-time support, we can try it :D :D
     
    Last edited: Sep 5, 2021
  21. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi.
    I baked an complete car interior with SH and BetterLit SH option and Lightmap specular is enabled in HDRP.
    When i enable Lightmap specular the highlights are very intense and blow out.

    I can post these screenshots tomorrow but for now it s also visible in your standard scene...

    Lightmap specular enabled on the SH Better Lit plane.

    z.JPG

    2t.JPG


    My complete car interior shows the same similar and extreme specular blown out like shown in first screenshot when lightmap specular is enabled.

    Could it be that there is some error in the shader?
    I would expect something around 1/3th of the specular intensity.

    Materials are scanned and have correct PBR setups.
    All Light Sources have physical plausible values.
     
    Last edited: Sep 5, 2021
  22. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    Is there a way to go beyond 64 GI samples or is this considered to be overkill ?
     
  23. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Yes: just click on the number and write your custom amount using the keyboard ;)
    It depends for what.
    If all you want is a good lit scene with no noise, then yes, it's overkill: you will not see any difference beyond 64 samples as long as you enable the denoiser.
    However, if you are doing dimly lit scenes with indirect light as your main source of light, then you will definitively need more than 64 samples, especially it you crank up the light bounces to 5 or more, since the more bounces the light does, the less rays reach those latest bounces, and you will end up with either artifacts or noise in very dim areas.
    In a general use case, however, even 64 is overkill: 32 samples with 3 bounces and the denoiser on will give you the best results.
    Also, keep in mind the Optix denoiser doesn't give perfect results and has a tendency to do some line dithering.
    The CPU Open Image Denoiser does a flawless work on this, but is much slower.
    So use the Optix one for work in progress and the Open Image Denoiser for the final lightmap render.
     
    guycalledfrank likes this.
  24. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Because it's COOL! :D
    With negative lighting you can do special effects!
    Reality is overrated! We can and should do BETTER! :D
    Now, seriously, everyone talks about "realism" as if it was the Holy Grail of computer graphics, when in fact "reality" is arbitrary and has just been imposed on us. Why limit ourselves to make things look "real" when we can make them look BETTER than real?
    If people liked reality, they wouldn't be playing video games, they would go outside™! :D
    And by "better", I mean "more pleasant to us".
    And that's the job of the artist: to make something that LOOKS as if it was real, but that is NOT and that is BETTER than reality because it has been tailor-made by a human to please other humans.
    We don't talk about the Dark Times of PC graphics! :D
    So... negative lights would be as easy as unclamping the Bakery Light component intensity value??
    MIND BLOWN!
    Seriously, you should REAAAALLY consider doing a sound baker that could bake all the audio reflections and store that in "sound probes" or something like that!
    That would be seriously GREAT: currently, no amount of audio spatializers can deal with sound propagation on indoor environments. Hell, even outdoor environments have pitiful sound ambience reproduction.
    And nowadays more and more people use headphones to play games, so it's painfully obvious when you have super realistic graphics and sound that doesn't match.
     
    guycalledfrank and hippocoder like this.
  25. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    Thanks ! Yes that's exactly what i'm doing ! Didn't know i could simply type the number. I'm not sure it is documented.
     
  26. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    Hi. is there an official discord?
     
  27. Object-Null

    Object-Null

    Joined:
    Feb 13, 2014
    Posts:
    70
    Hello,

    im not sure if this is bakery related, but im posting this because im using bakery and i don't know where else to ask.

    After my lightbake some light spots are visible in my lightbakes as you can see in my image.

    i tried used the 'scale in lightmap' option with different values but that does nothing. but i dont know where else to find this problem/solution for it so that the spots won't appear anymore.

    maybe it is also good to know why they appear in the firstplace.
     

    Attached Files:

  28. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Those are known as "fireflies"
    As per the docs:
    https://geom.io/bakery/wiki/index.p...oduces_scattered_bright_spots_.28fireflies.29
     
    guycalledfrank likes this.
  29. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
  30. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I'm trying to bake and it gets stuck at Scene_LMA10.
    Before was Scene_LMA20, and now Scene_LMA1.

    It' always one of these.
     
  31. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I got it fixed by just disabling "adjust sample positions".
    However it took me more than 2 hours to bake and everything marked as static look dark.
     
  32. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I added a Skylight and a direct light bakery component to my directional light.

    Same thing happens as before.

    It gets stuck here:

     
  33. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    As notice above, I am having problems with this "fireflies" as well but mine are appearing while using Area Light with Light mesh as a component. Reading the above mentioned documentation, is not of any use in my case. Does anyone have encounter similar issues with Area Lights? IF so what could the solution be to eliminate these fireflies? Is there something I am missing regarding the way to work with Area Lights from Unity and Bakery? Please help if you can.

    Regards,
    Carlos
     
  34. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Have you played with the close and far samples values in the light mesh component?
    It should fix that.
     
  35. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Maybe there is something wrong with your UVs.
    Is Bakery working fine with the included sample scenes in your system?
    If the sample scenes render fine, then it's something in your scene that isn't playing nice with Bakery.
    If the sample scenes have any trouble, then it's related to your system's config.
    Let's start with that.
     
    guycalledfrank likes this.
  36. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Sorry I forgot to mention that this happens in an Area Light, that can't use self shadowing since doing so it would block the sun. The others got fixed by playing with the near and far samples indeed. My bad.

    So this specific one, is in a window where the sun goes through directly and the Area light is there, if I make the area light self shadowing then I can't see the sun's light passing through the window. but if the area light(with the light mesh component in it) doesn't cast shadow the near sample is greyed out. And based on the other area light this is the only way I have found to fix the fireflies problem. Is there another way to fix this?

    Regards,
    Carlos
     
    Last edited: Sep 8, 2021
  37. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Not that I know. I'm afraid this is a job for Super @guycalledfrank !
     
  38. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    Any idea why my orange light is turning into green ? It is full baked. The green is on the GI map.

    This scene is haunted.
     
  39. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937

    Here is my Shadowmask Directional SH bake problem on real world geometry.
    There is one baked big mixed shadowmask area light over the car to get some nice null lighting.

    Check the black leather steering wheel material as example.
    Here is the Shadowmask Directional SH bake output for this material.



    This is looking nice.
    See Better Lit settings in the material setting window.




    When i enable LightMap specular in the Better Lit i get this overblown speculars on the steering wheel.
    See Better Lit settings in the material setting window.
    Same overblow for all other car interior materials not shown here.




    Lightmap view.
     
    Last edited: Sep 19, 2021
    guycalledfrank likes this.
  40. Goldenvale

    Goldenvale

    Joined:
    Feb 26, 2015
    Posts:
    86
    Hi Frank,

    I just switched to an RTX 3070 and baking works great but I came across some errors when baking with atlas packer and unwrapper. I'm using open image denoise and RTX mode is on.

    Screenshot 2021-09-08 174713.png Screenshot 2021-09-08 174813.png Screenshot 2021-09-08 174851.png

    In the .ftracelog file it says the same:
    Code (CSharp):
    1. Used host memory: 0mb, available GPU memory: 7132mb
    2. MODE: postmaskadd
    3. USING FLOAT
    4. Loading shader postAddMask.ptx::oxMain...
    5. Error (1540): File not found (Details: Function "_rtProgramCreateFromPTXFile" caught exception: File not found - postAddMask.ptx)
    6.  
    7. Error in PTX
    8. Error (1280): Invalid context (Details: Function "_rtContextLaunch2D" caught exception: Validation error: Ray generation program 0 is null)
    9.  
    I'm using Unity 2019.4.15f1
     
    MCcccc, feiyang1 and guycalledfrank like this.
  41. MrPapayaMan

    MrPapayaMan

    Joined:
    Feb 16, 2021
    Posts:
    42
    I seem to be getting stuck at "adjusting sample points for lightmap." Any ideas where I can look to troubleshoot?

    Edit:

    NVM. Working again. ¯\_(ツ)_/¯
     
    Last edited: Sep 8, 2021
  42. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Detail View

    So, when this not a bug it would be cool to have an Lightmap specular intensity slider in the BetterLit.
     

    Attached Files:

    • 8.JPG
      8.JPG
      File size:
      19.9 KB
      Views:
      571
    • 9t.JPG
      9t.JPG
      File size:
      17.3 KB
      Views:
      561
    Last edited: Sep 19, 2021
    guycalledfrank likes this.
  43. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I just deleted the skylight and now it works but everything looks dark, it took 8 hrs to bake
     
    Last edited: Sep 8, 2021
  44. Noors84

    Noors84

    Joined:
    Jul 12, 2016
    Posts:
    78
    Denoise : fix bright edges was the issue.
     
    guycalledfrank and wetcircuit like this.
  45. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    Just changed the texels to 5 and render mode to shadowmask and it's working fine now :)
     
    guycalledfrank likes this.
  46. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    ---------------------------
    ftrace
    ---------------------------
    Error (-1): Unknown error (Details: Function "_rtContextLaunch2D" caught exception: Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (700): Illegal address, file: <internal>, line: 0)
    ---------------------------
    OK
    ---------------------------

    upload_2021-9-8_22-17-50.png

    upload_2021-9-8_22-19-38.png

    I get this with latest bakery + RT Preview, possibly a cookie problem?

    Can you help solve it please :)

    To reproduce, add a bakery spotlight and enable preview then move the spotlight around.
     

    Attached Files:

  47. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I have a scene where I use outdoors and indoors. How can I make it so that there is no shadows outside but there ire shadows inside?
    The scene is cloudy/misty so I don't need the shadows outside, but the interiors are completely dark.
     
  48. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Don't use any lights in the exterior and light your scene only with the skylight.
     
  49. matiasges

    matiasges

    Joined:
    Jan 24, 2021
    Posts:
    142
    I added skylight and deleted the directional light. But it gets stuck when baking when I add a skylight.



    It gives me 2 warnings:



    Could be that the problem?

    I tried a sample scene with a skylight and it works fine. No idea what I'm doing wrong.

    I bake with these settings:



     
  50. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    The settings seem to be ok.
    Be sure to read the docs about skylights.
    Check also the Quick Start section, it shows you how to create a skylight step by step.