Lightmapping

Calculating lighting in a scene is one of the most time-consuming tasks of any engine. Often due to the use of a large number of light sources the performance of the game can drop significantly, which will naturally annoy players, even if your game is very interesting.

Lightmapping is a technology that on the one hand improves the performance of your game, and on the other hand gives you a high quality image that is close to what we see in the real world.

Lightmapping involves baking light sources into textures and then ignoring the calculation of these sources during the game. As an added bonus, you get a picture with realistic lighting, shadows and occlusion of the environment.

General recommendations for using lightmapping

The process of baking lightmaps is a resource-intensive operation, both in terms of time and performance of your computer.

Therefore, it is advisable to make the decision to use lightmapping at the initial stage of development, it will help you to build your game scenes correctly and avoid wasting time and your efforts.

We recommend to bake light sources at the moment when the gameplay and appearance of the game or a separate scene of the game will be fully completed, it will significantly reduce the development time.

For mobile development, try to avoid lightmapping at all or use low quality settings.

Preparing for baking

Before baking a lightmap, you need to decide which objects will be baked and which will not. In the vast majority of cases, only static objects are suitable for baking. We do not recommend using dynamic or kinematic objects for lightmapping. Use the opportunity to bake dynamic and kinematic objects as experiments, perhaps the end result will satisfy you.

Do not use a large number of dynamic or combined light sources.

When baking closed rooms, locations that are illuminated only by artificial light, turn off the Sun in the environment objects, so you will get the right result. Otherwise, the picture may be illuminated more than you intended

Combine light sources and objects with materials with Emissive map, to achieve faster and better results, instead of using a large number of light sources.

To mark an object as ready to be baked, in the Object Inspector under the Properties tab, in the Lightmapping section, turn on the Bake in Lightmaps toggle.

Light sources in the lightmapping section, in the Object Type setting have 3 options:

  • Realtime - means that this light source will not be taken into account when baking lightmaps and will behave and be calculated like a normal light source. Dynamic objects will be illuminated by this source. Baked objects are not illuminated by this type of source.

  • Baked - means that this light source will be taken into account when the lightmap is baked. This source will immediately stop affecting the scene as if it were turned off. Don't worry, after the lightmap is baked you will see the result of its effect on the scene. To see this source, change its type to Realtime or Mixed.

  • Mixed means that this light source will be count during lightmap baking, but will affect both dynamic and static objects without lightmap. This light source will have no effect on baked objects. Use such a source in places where the appearance of dynamic objects (for example, the Main Character or NPC) is inevitable.

To select objects that will be baked with a certain quality, there is the Bake Volume tool. Before creating bake volumes, decide which objects require high bake quality and which can be shown with lower quality.

Last updated