Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. 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

How Are Light-Baked Prefabs Supposed to Work?

Discussion in 'Global Illumination' started by John-B, Jan 23, 2019.

  1. John-B


    Nov 14, 2009
    There is a very long thread on this topic with lots of slightly different code snippets and conflicting sets of step-by-step instructions. I believe I finally got it working, at least it looks like it, but I'm not sure if it's really helping performance.

    I have a test scene with a few static objects that use a baked light map. At runtime I instantiate about 25 different prefabs in the scene. Before I starting trying to bake the prefabs, the Stats window showed 79 batches, 57.3k tris, and 33 SetPass calls. It runs at about 240-250 fps in the Editor. That's my baseline. I took 6 of those prefabs that all share the same material, set them to static, and baked their light maps as discussed in the thread linked above. The scene uses 4 non-directional light maps, 64 MB. Aside from the baked prefabs being a bit dark, it appears to be working. However, now that test scene shows 1298 batches and 35 draw calls, and the frame rate is up slightly to around 250-260 fps.

    This is not a big sample, so I wasn't expecting big effects on performance, but I didn't expect batches to go up, let alone by 16x. And I didn't expect SetPass calls to go up either. I'm not sure the slight difference in frame rate is significant. I was expecting fewer batches and fewer SetPass calls. Isn't that what should happen? Does it sound like I'm doing something wrong with the prefab baking? I don't want to spend a lot of time tweaking the lighting and baking the rest of my prefabs (about 100 different objects) if it's hurting performance.
    Jay-Woody and Shorely like this.
  2. Jay-Woody


    Aug 22, 2015
    I would very much appreciate an in-depth tutorial on this matter. I started building my procedural assets and was surprised to find out that baking lightmaps to prefabs isn't built-in in the engine. Seems like a pretty important aspect for procedural generation.

    Haven't gotten the script to work yet and I know I'll be using some time to this, which is a bummer.
    sivrikaya and fguinier like this.
  3. fguinier


    Unity Technologies

    Sep 14, 2015
    We don't have an offical doc on this indeed, there are plan to have such a doc but no ETA at the moment.
  4. Rich_A


    Nov 22, 2016
    Any updates on this, 15 months later? :)
  5. Alexaroth


    Feb 4, 2019
    Imagine focusing engine development efforts on features like ECS and other state-of-the-art features, while a simple thing like baked in lighting for prefabs is not supported years down the line...
  6. cineconcerts


    Dec 18, 2019
    I can't get any method to work. Really sucks.