Bake as much as possible

Baking as much as possible should be your initial approach to lighting on a mobile platform using Unity. Lightmap baking is the process of calculating the effect of lights, like illumination and shadow, and storing this information in a separate texture called a lightmap. A lightmap can be used to augment the appearance of objects. By performing this baking process, you only need to do the offline computation once. There are no extra performance costs at runtime. 

Pre-baked lighting does not cope with the dynamic, or moving, aspects of your scene. However, prebaked lighting does include global illumination for all the static elements. This means that each static element gets the indirect light that has bounced off objects and the direct light for the static lighting. The following image shows an example of a fully baked scene.

Baked lights

Unity makes it easy to bake lights. There are two main steps that you must set up before you can bake your lights

  1. Click Windows > Rendering > Lighting Settings and set the lights that you want to bake to either Mixed or Baked

    Baked setting

    For mobile titles, use baked lights instead of mixed whenever possible. This is because baked is the least expensive of all the options. 

  2. Mark objects that receive the baked light as Static:

    Inspector settings  

    There are multiple possible optimizations for an object to be marked as static, but usually we have Everything selected in the settings. With the object marked as Static, Unity knows to include it in the light baking.

Note: With Batching Static enabled, you will not be able to move or animate the marked object. This is another optimization and should be left on wherever possible.

When you are baking your lights, remember that the data is saved based on the scene that was active when you started the bake. A folder is generated that has the same name as the scene that you just baked. This is where all the components for the lighting data will be stored. If your project uses multiple scenes that are loaded at one time, each scene needs to have its lights baked. If you adjust your scene, you need to rebake the lights. The following image shows where that folder will be created.

Light data

Previous Next