Balancing Static & Dynamic Objects when Baking In Unity
HD game development is often pushing the limits of current technology, and solutions need to be optimised effectively.
Today’s Objective: Explore how a Unity developer can understand how light baking works, the costs it involves, and how to balance performance with quality effectively.
Static Baked Lighting:
When using Baked Lighting in Unity, it is a requirement that all objects to be affected by the baked lighting be GI Static themselves (except when using Light Probes, discussed later).
But if you want to light up most, or all, of the objects in your scene using a baked light, such as a directional light, that will lead to a lot of Static objects. The more Static objects, the more light bounces, and the more calculations for Unity to work out. And most of those calculations will have very little impact on the scene appearance.
Optimizing the performance cost:
Doing the above is not the only method though. There is a way to “have the best of both worlds” with your scene lighting.
First we need to think about our scene, and determine which parts are vital for great lighting:
Generally, the objects that cover the largest area are usually the ones that are important, and possibly should be GI Static.
After consideration of my scene, out of the at least 100 different objects in the scene, only the floor and carpet are important to lighting. I could include the ceiling and walls too if needed, but for now I won’t.
The carpet is important because a bright light shines on it, which would reflect the carpet’s colors onto surrounding surfaces. Otherwise, I wouldn’t include it.
After setting only those objects to GI Static in the Inspector, and everything else being dynamic still, we can move to the next step.
I mentioned before that only GI Static objects are affected by baked light, except when using Light Probes. We now have our important objects lit by baked light, but everything else is still dynamic and lit incorrectly/unrealistically.
The solution for this is to use Light Probes to convert the baked lighting data into lighting data that all the dynamic lights can use.
Now, all the dynamic objects receive the baked lighting data from the baked light indirectly, through the Light Probes distributed around the scene.