Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity Progressive CPU Lightmapper

Discussion in 'Global Illumination' started by Kuba, Feb 2, 2017.

  1. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    411
    Hey @AcidArrow, sorry to hear about your bug reporting experience. ;(

    Our QA does their best to try to reproduce the bug in various environments, on different Unity versions (to e.g. prove whether something is a regression), etc. It might sometimes happen that we ask you for more information too hastily. Please don't take that as us throwing the issue back over the fence. It's just a way to gather more information that we are currently missing.

    I understand that it might feel like we're putting the burden of gathering more info on you. That's not the intention. It's just one way for us to learn more about about the issue. It's perfectly fine to answer "I don't have more data.".

    Within the team we have frequent conversations between QA and devs about bugs that can't be reproduced to brainstorm on possible ways of approaching the issue. Also, it's of course not strictly needed for us to reproduce the issue to be able to fix it, but that makes it much faster. That's why it's the first thing that we try.

    I really appreciate the amount of work you've put into reporting bugs and hope that we didn't lose you forever.

    Cheers,
    Kuba
     
    Jesper-Mortensen likes this.
  2. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    Tried reproducing this myself. Here is the result:


    Am I doing it wrong? This is on windows with Unity 2019.3f4. Have you tried this on windows? Potentially it is Mac specific.
     
  3. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    We added the option to crank up the sampling for probes now. This helps a lot in these cases, where lighting is difficult to find. It shipped in 2019.3.
     
    Lars-Steenhoff likes this.
  4. Stanislawe

    Stanislawe

    Joined:
    Mar 26, 2015
    Posts:
    44
    I also reproduced case 1207489 in 2019.2.15 and 2020.1.0.a16, Windows, only gamma space (linear no problem)
     

    Attached Files:

  5. kslusarz

    kslusarz

    Joined:
    Mar 1, 2018
    Posts:
    7
    Hello,

    I've posted some time ago my little issue with onesided meshes casting those buggy shadow :
    https://forum.unity.com/threads/lightmappers-buggy-shadows.784130/

    Now I read I'm suppose to change the backface tolerance. I've tried few values ( 0.0, 0.5, 0.9, 1.0 - not exacly in that order) and while there's some difference, it still looks equally bad :(

    Is there any way to fix that problem?

    Adnotacja 2020-01-16 170027.png Adnotacja 2020-01-16 170027.png Adnotacja 2020-01-16 170103.png
     
  6. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    If you have open meshes use a material with Double Sided GI enabled on the meshes that are open (not the ones that the artifacts appear on!). In HDRP the Double Sided GI property is automatically set if you make the material double sided.
     
  7. kslusarz

    kslusarz

    Joined:
    Mar 1, 2018
    Posts:
    7
    Thanks again :).
    What are the side effects (performance or baking time) of using doublesided GI?
     
  8. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    It’s negligible. But of course you will be tracing paths from those broken texels, but that’s unavoidable, and desirable too. Hope it works for you now. I am considering changing the behaviour for this.
     
  9. dgoodman-icf

    dgoodman-icf

    Joined:
    Jan 7, 2019
    Posts:
    31
    Where is this option found?
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    In settings or prefs. Dig through and it'll be in one of them. It won't be on the actual probes.
     
    dgoodman-icf likes this.
  11. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    Yes as @hippocoder says you can find it in "Edit->Project Settings->Editor->Use legacy Light Probe sample counts" it should be unticked to use the new way of specifying Probe sample counts. It is an option like this to avoid breaking upgraded projects. I you hover the greyed out setting in the Lighting Settings window it will also point you there.

    Cheers,
    Jesper
     
    dgoodman-icf and hippocoder like this.
  12. dgoodman-icf

    dgoodman-icf

    Joined:
    Jan 7, 2019
    Posts:
    31
    Oh wow I never would have looked there! Thanks much :)
     
  13. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    197
    Is it better to scale the world and the player down to 0.2 meters if you want to get less lightmap size.
    The usual would be to have player 2m tall and scale the world accordingly. But, does that use bigger lightmaps since it's is greater distance to world's origin.
     
  14. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    That's not a good plan. Use the scale in lightmap parameter for meshes.
     
    JoNax97 and Mark_J18 like this.
  15. Mark_J18

    Mark_J18

    Joined:
    Aug 11, 2014
    Posts:
    46
    Change the scale of the lightmap resolution globally (via the lighting window) or as hippcoder suggested, on a per object basis via the meshes lightmap settings.
     
    hippocoder likes this.
  16. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    To climb Everest... I will scale these heights!
     
  17. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    197
    Does lighmapper have internal importance boundary volumes around geometry ? I would control light baking with boundary volumes.
    For exmaple, if you bake lighting for interiors, areas outside the importance volume should only get one bounce of indirect lighting at a lowest quality.
     
  18. eiwzkart

    eiwzkart

    Joined:
    Feb 25, 2016
    Posts:
    4
    I use CPU render and this is happening to the same object at difference transform, so weird

    really cannot figure out what is wrong, as I research deeper, it turned out to be the shadowmask map is not correct(one face is getting some black spot) if the box is at distance transform(for example x=2500),

    it also happens to the enlighten renderer

    upload_2020-5-10_13-11-28.png

    upload_2020-5-10_13-8-39.png
     
    Last edited: May 10, 2020
  19. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    164
    You may be seeing self intersection artifacts when you're far off the center. Adjusting the pushoff value in the parameter should fix this.
     
    JamesArndt likes this.
  20. Zylex

    Zylex

    Joined:
    Nov 25, 2008
    Posts:
    201
    Does upgrading memory help when baking with CPU? I currently have 32 GB and I see it nearing 30GB while baking. Would it speed up if I had 64GB?
     
    JamesArndt likes this.
  21. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,827
    I would say that RAM would play a small role, but not substantial considering how much RAM you do have. 16GB works efficiently for most scenarios and you're doubling that. Most of the speed for the CPU Lightmapper is likely going to come from your CPU and motherboard configuration. The better a GPU you have, the better the GPU lightmapper will work.
     
  22. Stanislawe

    Stanislawe

    Joined:
    Mar 26, 2015
    Posts:
    44
    How progress?
     
  23. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
  24. cwrightvdi

    cwrightvdi

    Joined:
    Apr 29, 2020
    Posts:
    4
    Is anyone else having an abnormally large GI cache? I am using 2019.3.13 and baking large scenes with the Progressive Lightmapper and while I am using 2048 maps and a texel resolution of 10, I do expect there to be a big cache. But, my scene's lightmaps are only a total size of 5.98 GB and my cache is well over 200GB. Is this normal? Does baking multiple scenes continuously add to the size (I have baked about 3 all of the same size and asset types)? Is there a setting besides the Cache compression toggle (which I have on in the GI cache prefs) that may be helpful to reduce this?
     
    Last edited: May 27, 2020
  25. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
    Yes, you can manage the size, location, and compression of the GI Cache using the GI Cache preferences. For more information, see https://docs.unity3d.com/Manual/Preferences.html#GI-Cache.See https://docs.unity3d.com/Manual/GICache.html for more details about the cache itself.
     
  26. cwrightvdi

    cwrightvdi

    Joined:
    Apr 29, 2020
    Posts:
    4
    So in essence, no there is nothing else I can do. Those preferences I already have set. There's not much to them. Cache compression is on and the size I have set to 200gb (that obviously does not limit it as my cache is currently 230+gb). So is this the normal? I have done this same baking in previous versions of Unity and the cache never got over 100GB. Did something change in Unity 2019? Is this possibly a bug?
     
  27. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
    Unity will hold on to GI Cache data which is still in use by the current bake, but 230GB does sound like a lot, if your scene is huge this is not unrealistic though. You can use the Editor GI Cache preferences window to clear the GI Cache but then your next bake will start from scratch instead of getting a speedup from the cached data.
    Please do keep in mind that the biggest user of GI cache data is Enlighten, for both precomputed realtime GI and baked lighting. The Progressive CPU lightmapper doesn't produce nearly as much cache data, so please check your settings - is realtime GI turned on?
     
  28. cwrightvdi

    cwrightvdi

    Joined:
    Apr 29, 2020
    Posts:
    4
    I have had Realtime Global Illumination turned off in each scene. I have been not wiping the cache as (in previous builds I had to do this) I need to share the baking cache between multiple coworkers or it will not apply correctly. As I mentioned they are huge world scenes but I baked the same scenes in a previous version of our product and they did have a smaller cache. If I can clear the cache and not have to share anymore between coworkers' machines and the several baked scenes will still look correct than this is not as big of a worry.

    So, is it possible to clear the cache and not lose or disorient the baking data between editors on different machines?
     
  29. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
    There is no need to share the GICache with your co-workers, all the baking outputs is stored in the LightingData asset, see https://docs.unity3d.com/Manual/LightmapSnapshot.html for more details.
     
  30. cwrightvdi

    cwrightvdi

    Joined:
    Apr 29, 2020
    Posts:
    4
    I do believe there must be a bug. After baking four and a half scenes my GI Cache is 471GB. It is now causing crashes so I cannot complete a bake. I would file a report but this project is not my own and is far too large. I may be having issues with old assets. Is it possible using old/out dated shaders or trees could cause memory leaks? Just curious because like I said I baked these same scenes in Unity 2017 and the cache never had this problem.
     
  31. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
    If you do believe there is a bug, please report a bug we can investigate the issue https://unity3d.com/unity/qa/bug-reporting
     
  32. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573
    Can you help me solve these white streaks in the intersecting objects. I am using the default very low resolution lightmap map parameters. I have tried to change the settings there with no change.
    These are Unity default cubes that going through each other at the cross intersections.
    The lightmap settings are mostly default.
    I am using progressive, no ambient occlusion. Mixed lighting-realtime with a baked indirect lightmap.

    Image 3 clearly shows that these 2 cubes have been stretched as rectangles and they cross intersect with each other so this issue is happening at cross intersections and that's why UV error mode does not show any errors.
     

    Attached Files:

  33. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    7,031
    These do nothing with PLM.
    Remove Gaussian filtering.
     
  34. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573
    Hi there removing guassian filtering or even setting all the filtering to none did not show any change.
    I wonder if this has anything to do with the UVW2 of default unity models for the lightmaps.
    Their import settings are not editable so I don't know what to do.
     
    Last edited: Jun 23, 2020
  35. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Hi,

    I have serious problems with both CPU and GPU lightmapper. During the baking process, my device shut down and then restarts. I'm on Unity 2019.4.1f1.
    It never happened during any other baking process, I'm also using blender and Unreal.
     

    Attached Files:

  36. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573
    You won't find much advice here. For things like that I would highly advise submitting a bug report so someone from Unity can help you through email.
     
    KEngelstoft likes this.
  37. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Ok, I baked with the CPU lightmapper because I do not have enough VRAM to bake my rather large scene any longer with GPU. And I noticed a very huge difference in the outcome of light bounce between CPU and GPU lightmapper. Basically with CPU, everything covered with shadows is mostly pitch black resulting in no GI. GPU seems to be ok.
    Basically I let my computer burn for 3 hours just to get the light bounce missing on most of my surfaces? Now it's worse than without GI. Why is everything mostly pitch black?

    I'm on Unity 2019.4.1f1 with HDRP 7.4.
    Don't know if this is related to the problem, but before the 3 hours CPU bake went successful I had another PC shutdown caused by CPU lightmapper. This also results into my local Unity project got marked by Unity Collab as out of sync "Merge conflicts". I had to reimport the complete project from Unity Collab ...
     

    Attached Files:

    Last edited: Jul 6, 2020
  38. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573
    Your device is shutting down because HDRP is too much for it. Switch to Vanilla or LWRP.
    I see that you are using HDRP and my advice is for Vanilla Unity for the AO help but you might be able to find another AO solution for HDRP if you like. Judging by your computer meltdowns I don't think HDRP is for you HDRP behaves differently from the ground up only for the highest of platforms and to make this clear I get 30 fps in the sample scenes with HDRP and I get 300 fps in LWRP and 300 in Vanilla Unity without there being much visual difference so I highly suggest you rethink your setup if it's not too late. In the meantime I can help you with a rundown of of some of these:
    -There are a few concerns here like your PC crashing and burning.
    -Taking 3 hours to bake tells me you are using the wrong settings-use the default settings in a new scene and see how you go.
    -The difference you are talking about is likely because the GPU Lightmapping is in Beta and not yet as far along as the CPU.
    - If my advise below is of not much help then you should just file a bug report and work with them.
    -I advise you look into lightmapping once again to understand it better because 3 hours isn't making sense to me and you should be pre-baking with very low settings to see your lightmaps before going for the final bake.


    -If you choose to go revert from HDRP and choose vanilla I will share my settings but they can still be ported if you know what you are doing to LWRP and HDRP and if you can figure it out you won't even need lightmapping at all.
    - For indirect lighting get the now free Amplify Occlusion (Vanilla Unity only) and follow the settings I uploaded. With that you won't need baked lightmapping at all and you can use real time lightmaps only as a bonus. For HDRP you can use other screen space AO instead.

    I have uploaded my settings I use in Vanilla and am very pleased with. It has eliminated the need for lightmaps and I also chose to use realtime lightmapping but if I disable it it won't affect look that much since the AO is doing most of the work for indirect lighting but I add it in because it's so cheap and no issues outside the default settings. Sorry I couldn't be of more help so I just threw everything at you haha lightmapping in Unity is still broken even after all these years.
    Also there is an extra Vsync toggle
     

    Attached Files:

    Last edited: Jul 7, 2020
  39. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    I know GPU lightmapper is still in preview but regarding my screenshots the CPU lightmapper produces the wrong light bounc (see the pitch black GI) when GPU lightmapper produce nice results (see the comparison screenshot). The lightmaps seems to be ok.
    FPS is not really a problem for HDRP. I get over 90 fps most of the time for my project. Right now my only concern is the lightmapping is not usable to me: 1. GPU lightmapper ask for way too much VRAM. 2. CPU lightmapper causes pitch black areas. 3. Enlighten is deprecated.
     
  40. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573

    Ah I think I understand your issue now! Your issue is not a bug or an error with the GI bounce.
    The GI bounce in the lightmap settings doesn't affect the issue you are talking about.
    These are some of the things that can affect the result of the shadow:

    I think the biggest factor for you would be the settings on your light and shadows and skybox.
    Change the values of your environment lighting from Skybox to Color and increase the brightness to affect the darkness and bounce of your lighting.
    Also if you use realtime GI or Baked GI then on your light there is something called the Indirect Multiplier set it to 0.5 for example and it will lighten or Darken the Bounce from GI in shadowy areas but it only works if you have realtime or baked GI done.
    *All of those settings are already included in the pictures i attached of my last post.
    Let me know if that fixed your issue and in the meantime make sure all of your texel densities and sample counts are default or low to speedup lightmap render times until you resolve your issue then you can up them to final bake.
     
    Last edited: Jul 7, 2020
  41. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    I use the Physically Based Sky with a Multiplier of 1.5. I also set the Static Lighting Sky to Physically Based Sky and assigned my Sky and Fog Volume properly.
    My sun has the default strength of 3.14 lux.
    For the Indirect Lighting Controller, I set both Indirect Diffuse and Indirect Specular to 1.0.
    I use Mixed Lighting with Baked Indirect.

    Now the results of GI are nice, like I want them, because I adjusted everything many times. But by that time I used the GPU lightmapper. Now my scene increased in complexity and have no longer enough VRAM to bake with GPU. So I switched to CPU lightmapper and I get the pitch black areas where the realtime shadows are. So do not understand this difference. Why is this not a bug?
     
  42. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,233
    Hi, is it possible to distill your scene down and file a bug report? The GPU and CPU backends produce very close to identical output in most scenarios. I would like to investigate the cause of the differences in your scene.
     
  43. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Now I tried a lot of different settings with the CPU lightmapper and I noticed the main impact coming from the lightmap size. If the lightmap size is equal or less then 256 px, I get the same blue nice looking GI like in my screenshot with GPU lightmapper. But as soon as the lightmap is greater than 256 px, I get brown or pitch black GI from the CPU lightmapper.

    I'm uploading a huge bug report but it's still at 86%.
     
    Last edited: Jul 7, 2020
  44. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Ok, I think the waiting time was for nothing?
     

    Attached Files:

  45. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Short question: Does the baking cost increase linear or exponentional if the lightmap size is increased?
    The same scene under the same conditions have this estimated time for me:
    256 px lightmap = 30 minutes :)
    512 px lightmap = 4:30 hours :eek::eek::eek:
     
  46. xanzarx

    xanzarx

    Joined:
    Dec 4, 2013
    Posts:
    4
    Hi. I have a problem with progressive lightmapper (cpu) on multi socket system. The problem is the lightmapper uses only half of available cores 32 of 64 (on single numa node).
     

    Attached Files:

  47. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Is this thread dead? No answers on my issue since weeks. :(
     
  48. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    164
    baking times depend on the scene a lot. Just bumping the resolution should result in fewer lightmaps overall (depends on scene setup as well), so the total time shouldn't change much if all you've done is bump the resolution in the lightmap settings.

    With regard to your dark lightmaps when using the CPU lightmapper, it looks like you're missing the sky influence (that's what the blue tint is). This shouldn't be related to lightmap size, though, and we haven't seen this specific issue before. A small repro would help us looking into what's going there. In the mean time I suggest double checking the HDRP's sky is setup, there's a specific setting for the baked sky that also needs to be set up correctly.
     
  49. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    474
    Thanks for the answer, but I did not changed my baking settings at all, I just increased the lightmap resolution from 256 px to 512 px. Baking time before: about 30 minutes. Baking time now: More than 2 hours.

    About the other issue: I read there is a bug when custom Shadergraphs don't have the exact same property names hardcoded for the lightmapper like "_COLOR", "_CUTOFF".
    I updated all my custom materials manually and this seems to do the trick. Looks ok now.
     

    Attached Files:

    • time.png
      time.png
      File size:
      138.9 KB
      Views:
      15
    Last edited: Jul 23, 2020
  50. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    214
    The baking time is proportional with the number of "Occupied Texels" this number is listed when baking. When using a lightmap size of 256 there are 112.8K texels in your lightmaps, when the size is 512 there is 1.1M texels, for this reason the baking time should be roughly 10 times higher.

    The reason that more texels are generated when opting for larger lightmaps is that objects that do not fit in a lightmap, are scaled down automatically to fit, so the number of texels allocated will be smaller with smaller lightmaps, because the UVs are squeezed down to fit.
     
unityunity