Search Unity

Bake gets stuck every time

Discussion in 'Global Illumination' started by PinheadRatthew, Jul 1, 2021.

  1. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    Hi :) ,

    I have been trying to add some basic lighting to my unity scene, but every time I try to bake lightmaps, it gets stuck on 'Preparing bake'.



    Also, the estimated time to complete this stage continuously goes up as I wait - after about 5 minutes of waiting, the time has gone from 10 seconds to 4 hours.

    I have reinstalled the recommended unity version, and tried creating an entirely new scene for testing, but the problem still happens and I cannot complete a lightmap.

    Any help on this would be appreciated :)

    Thanks
     
    DavidZobrist likes this.
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    This means:
    1.You have used high resolution for lightmapping
    2. Your system is low end
    3. You have used CPU lighmapper that is 10x slower than GPU

    Please tell us your system specification
     
  3. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    Hi thanks for replying,

    My system spec:
    Ryzen 7 5800X
    GTX 1650S
    16GB DDR4

    I also tried lowering the lightmap resolution but this didn't seem to help.

    Baking with the GPU is what seems to crash Unity, it seems after I try GPU baking I cannot bake at all again after that, but I'm not 100% sure this is the issue.

    Thanks :)
     
  4. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    what is your OS?
     
  5. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    I am on Windows 64 bit
     
  6. valarnur

    valarnur

    Joined:
    Apr 7, 2019
    Posts:
    440
    Have you created lightmaps for your assets?
    Has Unity generate lightmaps it or did you create in the 3D app?
     
  7. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    On my assets I enabled Generate Lightmap UVs and set the margin method to calculate
     
  8. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    This may help in some way, if I load the scene and do a CPU progressive bake, it works fine - but as soon as I try a GPU bake, it never progresses and unity can't be closed
     
  9. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    I had this problem on win 7 and when upgrading to the win 8.1 , it fixed
     
  10. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    Interesting , I'll wait until the next windows version and see if that resolves it

    Thanks for your help :)
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Since nobody's asked about the thing that affects the performance the most I will:

    How big is the stuff you're lightmapping? PLM is more affected by just how big it is in 3D space. Larger objects especially larger planes or a terrain, will require vastly more conservative profiles than a profile for an indoor section.

    This is where your performance is likely dying, so I'll just ask what exactly are you throwing at it? :)
     
    mcbauer likes this.
  12. PinheadRatthew

    PinheadRatthew

    Joined:
    May 24, 2021
    Posts:
    16
    I tried baking a very simple scene (just a small model of a gun) which worked perfectly fine when I used progressive CPU , but as soon as I tried the progressive GPU bake , it stops working

    Not sure if this is related but unity also doesn't detect the GPU until the bake has started - I have never had this problem with other software
     
  13. ZviNeug

    ZviNeug

    Joined:
    May 30, 2021
    Posts:
    3
    PinheadRatthew, I am having the same problem myself now. Did you manage to fix your issue? If so then how?

    I am using unity version 2021.3.4
     
    Last edited: Jun 28, 2022
  14. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    595
    Beyond what is normal. (normal is likely pinheads case)

    Normal being your level is set up for baking as effectively as you can at that stage
    This is related to Hippocoder's previous comment about the compositions of your objects because of PLM performance and essential knowledge to have when it comes to baking light data.

    There are times, with updates, multiple projects, cache data and general looping bugs that can cause the GPU/CPUs to just cycle this bake,

    in cases of 0% progression on a bake, this can be related to your GI cache data. (Possibly Extreme gamers case)
    GI cache can be deleted if it's been messed up in some way previously.

    A word of warning is that GI cache is shared between projects of the same editor version
    clear it only if you know it's okay to do so.

    This brings us to the looping bug: if a 2020.3 project GI bake crashed at some point, it is possible that the cache could affect all 2020.3 projects.

    To clear your editor version GI Cache
    • Open a project in the version you want
    • Edit
    • Preferences
    • GI Cache
    • Clean Cache
    • Restart project
    • Bake again
     
  15. ZviNeug

    ZviNeug

    Joined:
    May 30, 2021
    Posts:
    3
    What are the ramifications of cleaning the cache
     
  16. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    595
    The main one is that GI cache is shared across all projects within the ~same editor version, or globally on a computer if you do the same lighting processes.

    So you could unintentionally clear cache from another project, that you might also be working on or doing progressive bakes with.

    by default, the cache is stored globally like this, but you can set it to keep it in the lighting asset itself, which would be project/scene based instead.
     
  17. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    Here is a rule of thumb for lightmap baking

    1) Don't try to lightmap anything bigger than 200 x 200m scene - just never works
    2) Assign at least two weeks to optimize the scene for lightmap baking (for a dense 200 x 200m scene)
    3) Only lightmap big objects, and leave small objects for light probes
    4) Expect it to fail and be ready to iterate
    5) Higher quality options are not really viable because not only do they take long, but fail 99% of the time. Only raise quality when your scene is fully ready.
    6) Don't dream about test lightmapping on a WIP scene. It is a massive waste of time.
    7) Lightmap will easily get corrupt. Just be ready mentally.
    8) There will always be artifacts. Design your scene around it to hide it.
     
    Sarai, yoslan, Som4body and 2 others like this.
  18. ZviNeug

    ZviNeug

    Joined:
    May 30, 2021
    Posts:
    3
    I just cleared the cache, still have the same problem.
    the loading either stays at 0 and gets stuck, or shoots to a random number and gets stuck there
     
  19. Laym_

    Laym_

    Joined:
    Apr 22, 2021
    Posts:
    9
    Thank you so much! This ended up fixing it becuase my GI Cache was at 9.39GB Out of 10GB
     
    HIBIKI_entertainment likes this.
  20. Laym_

    Laym_

    Joined:
    Apr 22, 2021
    Posts:
    9
    Another thing to Add is if your Elighten ever gets stuck clear your Global Illumination Cache (GI Cache) And run the bake again
     
  21. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Oh so what is the solution for my terrain which is 4000x4000?
    Normally I can bake it with resolution at 2 but increase more than that will cause "Preparing bake" stuck. My PC is the powerful one.
     
  22. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    There is no solution...I have RTX4090, 16 core CPU, and 128GB RAM, still breaks. Go for Realtime GI if you have to have it.
     
  23. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    As you can see, my game has a lot of objects and I even turn of Real-time GI at the moment but the FPS is still not good due to direct light.
     
    Last edited: Oct 12, 2023
  24. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    524
    So for me, my lighting build was stuck on 5% for over a day. I had recently successfully built my level with no issues.

    All of a sudden, it is not happy about something.

    Turns out, I had a particle system set as static.

    Don't set particle systems to static.
     
    Last edited: Feb 16, 2024