Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question GPU Lightmapper failed -- out of memory (HDRP)

Discussion in 'High Definition Render Pipeline' started by Ichorcall, Oct 24, 2022.

  1. Ichorcall

    Ichorcall

    Joined:
    Mar 1, 2021
    Posts:
    1
    Hello everyone, I'm baking a large scene with many objects, verts, and batches, which I optimize the most I can with the asset MeshBaker, combining texture atlases and meshes to help reduce drawcalls. All texture atlases are either at 256 or 512 resolution (given they're background objects) and objects closest to the player are 1024, and in rare cases 2048. No 4k quality atlases in the scene that's being baked. I tweaked as many settings as I can and keep getting these errors, claiming my GPU is out of memory, which I want to confirm if this could be true using a pretty hefty graphics card? And the fact that I do have a lot of dedicated video memory.

    Baking has only been successful using 5 texels per unit over the course of 3 hours. Baking 10 texels per unit took 5 hours, which it bakes the entire way through like normal, until the very last minute it gives me the error and switches to CPU lightmapping.

    I even cleaned out GI cache and lowered AA settings to 1, in case those were causing it. Unity version is 2020.3.11f1.

    Is it also possible this could be caused by light probe groups? I have groups that span the entire scene and contain a lot. I imagine that I can't bake without them, however.

    Is the project truly too large for my graphics card to handle, or is there something I'm not getting here? This is my first time really baking a scene like this. Thank you!


    upload_2022-10-24_12-35-39.png


    upload_2022-10-24_12-40-52.png
     
  2. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Lightmapper received VRAM optimizations in 2021.2, and 2022.2 (the former is tiled baking, the latter is tiled denoising optix only) which should make it possible to bake your scene, but of course upgrading your project might not be a viable option for you. I would suggest disabling the denoiser and seeing if it's doable or not.

    Another idea is to switch some meshes in your scene to receive probe lighting, not lightmap -- mostly small meshes and objects that mostly receive direct lighting, very little indirect lighting. You'd have to setup light probes for your scene though.
     
  3. bonickhausen

    bonickhausen

    Joined:
    Jan 20, 2014
    Posts:
    115
    Never use Unity's built-in lightmapper. It's horrible.

    Get Bakery.
     
    PutridEx likes this.
  4. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,623
    But why? xD why people hates unity's lightmapper? xD
     
  5. bonickhausen

    bonickhausen

    Joined:
    Jan 20, 2014
    Posts:
    115
    Keep in mind that I am not affiliated with Bakery/its dev. The following is what I personally think of Unity's PLM (and I may be wrong in any/all of these points so feel free to test and draw your own conclusions):

    1- It's slow. Ran some benchmarks against Bakery and Bakery beat it every single time.
    2- I've had it crash randomly. Never understood why.
    3- The GPU PLM is still prone to errors/will often fallback to CPU PLM, where Bakery not only uses the GPU correctly (and flawlessly) but also has an optional RTX Mode for cards that support it, greatly increasing the bake speed.
    4- Unless you're using the latest HDRP version's Adaptive Probe Volumes (and let's face it: everything Unity has been doing lately has been wildly unstable/prone to errors because they never test their own stuff), you're stuck with Unity's old Light Probes to light dynamic objects and these are usually bad for any object larger than a meter. Bakery can bake its indirect lighting into a volume of L1 spherical harmonics which can then be read by shaders and result in far more detailed lighting for dynamic objects, since IIRC the lighting is then calculated per-pixel instead of having a single lighting term read at the transform's position and then applied to the whole mesh.

    I don't have time to deal with a half-baked toolset when I can just spend 50 bucks and get a lightmapper that just. works. all. the time. Maybe there are settings out there that do bring Unity's PLM to a very similar place to Bakery but honestly, I cba to spend any more time on that. I'd rather spend my time making games.

    TL;DR: Bakery just works. It just works.
     
    Last edited: Nov 14, 2022
    PutridEx likes this.
  6. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,623
    Lol So, is not horrible, is just your experience, i get it.


    For what i can see (in a tutorial from 2020) with bakery you can not do anything else while is baking, Maybe that is why the process with unity's lightmapper is slower, because unity bake in "background" mode, maybe... i mean, for me is very useful to keep working while unity is baking, so, i think at least for me, i prefer unity's way on this point.
    (EDIT: i'm watching a 2022 feature showcase of bakery and it seems like you actually can work while is baking and it looks faster but i'm not sure because the video is speeded up -.-")

    Well if you never understand why, then maybe is not unity's fault, you just take it as negative point even when you do not understand why xD... ok, i've working with unity for many years now and the lightmapper never crashed, maybe you are using alpha or beta version :/

    Ok here you have a good point, that also happened to me many times, maybe it has to be with the first point (the fact that bakery takes all your resources to bake) I know that has to do with lack of memory. Maybe if unity offered an option to bake like bakery, freezing your pc while baking it will be good for some users.

    IDK with other features but i can tell you, they test the APV, also, why are you talking about an experimental feautre?
    Why do people complain about those experimental features? XD this is something really weird for me xD, like, you guys do not understand why is experimental, alpha or beta features?

    I've been watching this Bakery for some years now and to be honest i fail to see something, some feature that worth buying it. I'm not trying to defend unity's feautres at all cost i know many of their tools fail, but right now in your 4 point you fail to prove why unity's lightmapper "is horrible" (at least for me and my humble and noob opinion XD)

    EDIT: Also, for what i saw, in bakery you need to add a component to every light and also modify again with the same settings of the actual light, so you need to make the work twice? o_O not exactly good for productivity, i also have to say that everytime i see someone complains about unity's lightmapper I'VE never seen a dev from unity defend their own stuffs xD so maybe haters are right hahaha
     
    Last edited: Nov 15, 2022
  7. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,623