Realtime, Mixed and Baked Light Modes — For Static & Dynamic Game Objects in Unity

Objective: To discuss the difference between Realtime, Mixed and Baked Light Modes whilst looking at which Light Mode might work best for our Sci-Fi lab room scene using Static and Dynamic game objects.

Compared to baked lighting, realtime lighting calculations are made at runtime (and not before) once per frame. Unlike baked lights, you can change the properties of realtime lights at runtime, being able to create some really cool lighting effects such as a flickering bulb or a torch being carried through dark room (such as the sci-fi lab room).

The limitations to using realtime lighting is that they can be quite costly (I was losing approx. 10 frames moving this around) and if players are trying to run the game on low end hardware this could cause some trouble. There is also the limitation of the light being only direct lighting, there is no indirect lighting effects such as a bounce of light on game objects.

The mixed lighting mode combines elements of both the realtime and baked lighting. This mode can be used to combine both dynamic shadows with baked lighting from the same light source. Or, when you are wanting a light to contribute direct realtime lighting and baked indirect lighting. At runtime, this mode allows you to change properties however, it updates the realtime lighting and not the baked lighting.

When we are comparing the performance of mixed mode compared to the other two, there will be differences when we are comparing to a full scene of either realtime or baked lights. Due to the fact that mixed lights always combine some of both realtime and baked lighting, there will be more runtime calculations compared to a completely baked lighting scene, and at the same time it will store some lighting information in memory so it’s performance will be improved than running a realtime only lighting scene.

These lighting calculations are made before runtime (and saved to the disk) through the Unity editor and are stored in something called a Light map. This is what we call Baking. At runtime, Unity then loads this saved lighting data to light the scene at the benefit of reducing shading costs. Unity bakes both indirect and direct lighting from light maps and light probes.

This light mode is best used when you know that the lighting won’t change at runtime, e.g. environmental objects that don’t move-walls, floors, ceilings, windows etc…that might have a fixed light on them.

As with the other light modes there is a trade off/limitations to using this type of light mode and that is not being able to change the properties of baked lights at runtime. Dynamic game objects are also unable to receive both light and shadows at runtime.

These are the game objects in your scene that do not move at runtime. Given that Unity precomputes information about static game objects in the editor, this information is still valid at runtime. So when we look at runtime calculations and performance, there is potential to save big time here! E.g. Walls, floors, ceilings, columns, archways etc…

So now if we were to say use a static wall with an attached baked light, this will help performance come runtime.

Alternatively to the above, if a game object does move at runtime, then this is a dynamic game object. E.g. Consider the player running around the scene. Further to this, the player might be running around with a torch (using realtime lighting) on static game objects (using baked lighting).

Passionate Unity Game Developer