Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Do baked shadows affect perfomance?

Discussion in 'General Graphics' started by radionix3d, Dec 21, 2015.

  1. radionix3d

    radionix3d

    Joined:
    Oct 25, 2015
    Posts:
    29
    I was wondering if baked shadows can seriously affect perfomance. They are just textures but I guess they are loaded into video RAM anyway and not streamed, so yes?
     
  2. Whiteleaf

    Whiteleaf

    Joined:
    Jul 1, 2014
    Posts:
    728
    I've always heard that baked shadows are much, much less intensive than realtime shadows. Whenever I bake my lights I sometimes get over a 100+FPS increase.
     
  3. Giometric

    Giometric

    Joined:
    Dec 20, 2011
    Posts:
    170
    This is pretty much exactly it; as opposed to calculating lights and shadows in realtime, the baked shadowmaps are instead loaded into memory and sort of overlaid on top of your models. It's a tradeoff in that you are going to use some extra RAM to store those textures, and spend a little bit longer loading your level to get them onto the video card in the first places, but in most cases, the big performance boost from not having to calculate lighting and shadows is worth it.

    The other tradeoff, unrelated to performance, is that your lighting will become static. Changing light colors, positions, directions, etc at runtime will have no effect on any baked objects, and if you move those objects around, you'll end up with shadow spots and other lighting inconsistencies. Depending on your use case, that may not be a problem, but always consider the kinds of things you're planning to do in your game before deciding whether or not to bake lighting.
     
  4. radionix3d

    radionix3d

    Joined:
    Oct 25, 2015
    Posts:
    29
    yes, thanks for reply! I was wondering - does Unity stream baked maps or does it load them all into memory once a level is loaded?
     
  5. Giometric

    Giometric

    Joined:
    Dec 20, 2011
    Posts:
    170
    I think the light maps for a given level are all loaded when you load that level. I'm not sure about whether Unity immediately unloads light maps for a level when that level is unloaded, though. I'm sure it does at some point, but I don't know if right away or if it waits 'til it needs memory for something else.
     
  6. radionix3d

    radionix3d

    Joined:
    Oct 25, 2015
    Posts:
    29
    So if we have like 2 gigabytes of lightmaps we're borked with most videocards on the market? As I understand lightmaps are loaded in videocard RAM, not general RAM, right?
     
  7. Giometric

    Giometric

    Joined:
    Dec 20, 2011
    Posts:
    170
    If you have 2GB of light maps in one scene, then yeah, most computers are gonna have a hard time with that. I don't know if that means a 100% 'won't run' deal, but I wouldn't expect that to do well even on a higher end system. Not to mention loading 2GB of textures and uploading them to the video card is going to take a while.

    Remember though, that is per scene. If you have 800 MB in one scene, 450 MB in another, etc, and it all adds up to over 2GB, that's still fine since you won't have all of them loaded all at once.