Optimizing lighting
We mentioned previously that not calculating lighting is good for performance, but what about not calculating lights, but still having them? Yes, it sounds too good to be true, but it is actually possible (and, of course, tricky). We can use a technique called static lighting or baking, which allows us to calculate lighting once and use the cached result.
In this section, we will cover the following concepts related to static lighting:
- Understanding static lighting
- Baking lightmaps
- Applying static lighting to dynamic objects
Understanding static lighting
The idea is pretty simple: just do the lighting calculations once, save the results, and then use those instead of calculating lighting all the time.
You may be wondering why this isn’t the default technique to use. This is because it has some limitations, with the big one being dynamic objects. Precalculating shadows means that they can’t change once they...