In today’s article we’ll be covering baked lighting, real time lighting, mixed lighting and when you should have objects set as static and dynamic in your scenes. It can be a little daunting at first especially as you experiment with different light sources and begin populating your scenes with lights that may or may not work as intended. It’s essential to your future productivity to know which to use as it will save you real hours of waiting for light to bake.

Let’s start with the simplest part which is deciding when and where to use static and dynamic objects. As you probably guessed static means not moving and dynamic means moving. In the context of Unity static objects are those that will not be moved by the player or otherwise like a statue or some other prop in your scene. Dynamic objects are things that move around the scene, this could be projectiles, the player, enemies, or whatever you want. When it comes to lighting and lights, they can be both static (a light fixed to a ceiling) or dynamic (a flashlight) or mixed (a lamp you can pick up and shine anywhere) objects. Let’s talk about static (or Baked) lights first.

Baked Lights (like the Area Light above) need static objects (like the walls around it) to display properly. They do this by creating lightmaps which overlay on the existing static objects. The downside of baked lighting is that they cannot change at runtime, they don’t do specular lighting, and they don’t capture dynamic objects shadows. The upside is once they’re baked they have zero overhead. So how do you make an object static? Simple just hit the little check box in the top right of the Object’s inspector. The drop down can further parse what kinds of static you want to make. If you want to make an object dynamic, just uncheck. It’s that simple, Unity assumes if it’s not static that it’s dynamic.

Realtime Lighting is the polar opposite of baked, these lights update every frame. If you move an object that casts a shadow in realtime light it will update on the fly. The downside is that this is very expensive computationally this also includes volumetric lighting and objects being lit. The other nice thing unlike baked lights is that realtime lights work on static and dynamic objects. You can parse out your static and dynamic light by realtime lights by using light layers (the article of which is here) to keep them organized. A good example of realtime light would be a spotlight, it is important to remember that all lights (except Area Lights) can be realtime and baked, you determine that in the settings.

The final kind of lighting is Mixed Lighting, this has all the pros and none of the cons of both Realtime and Baked modes of lighting but like everything else in life, nothing is free. Mixed lighting basically doubles up on the passes of the lighting system, this is a huge performance drain. This is probably the least common lighting mode due it’s intense performance requirements. You’re probably now wondering “When do I know to use Static or Dynamic?”

Easy! If you have a small number of baked light sources and a relatively small scene you could probably get away with marking pretty much everything static (barring the things that move like the player) but if your scene is large or with a lot of baked light sources your at runtime bake will be insane and might even crash Unity (or your game!) if you’re not careful. This is why you really need to think about what objects need to be static and don’t need to be static based on the kind of lighting you want. If light is coming through a window and shining down, consider leaving the ceilings dynamic and the walls and floors as static, if it needs to be more ambient then consider the ceilings.

Remember that baked lighting is light bouncing off static objects so by minimizing your baked lights (using light probes to project light from static objects to dynamic objects) is the best way to keep things performant. Additionally you need to keep in check how many realtime lights you have floating around, if you can better represent that light with an object with an emission channel or avoid using it all together you can save a lot of runtime performance this way. This is why it’s relatively rare (unless the game is highly optimized or has crazy system requirements) to see many realtime lights at once as the shadow casting calculations are expensive computationally speaking. Simply if you can avoid a realtime light with a baked light, a baked light (and static objects) with an emissive object and light probes, or no lights at all the better you will be. Be sure to experiment with static objects, baked lights, realtime lights, and light probes until you get a happy medium between performance and the desired look you’re looking for. Until next time, happy coding.