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 lighting 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 additional 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 a decision about using 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 advise you to bake light sources at the moment when 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 altogether or use low quality settings.

Preparation for baking

Before the lightmap baking process, 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 mixed light sources.

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

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 count 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 count 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 taken into count when baking lightmaps, but will affect both dynamic and static objects without lightmaps. 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 protagonist or NPC) is unavoidable.

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

As a rule, with high quality you can bake important details of the scene, the player's view and interaction with which will be relatively long. With lower quality you can bake the environment and large objects in the scene that the player will see from a distance or is unlikely to keep his eyes on them.

  • To create a volume, select the Baking Volume tool in the main MANU toolbar and click on it.The volume will be created in the scene in the selected hierarchy.

  • Drag the volume to the location of the objects you want to bake.

  • Enable the volume transformation gizmo (it is preferable to use this gizmo instead of the regular object transformation gizmo).

  • Transform the gizmo so that the objects you are going to bake are completely inside it. Lightmaps of objects that are not inside the volume will not be baked completely.

  • Repeat the action for other objects or locations creating other volumes.

Recommendations for creating Baking volumes.

  • Divide game locations into different volumes.

  • Do not create large volumes with many objects inside. The process of baking large volumes is time-consuming, fixing one bug in a large volume will require rebaking the entire volume and doubles the time.

  • Try not to overlap volumes partially, this can lead to lightmap conflicts and needlessly increase the game's resources.

  • If one volume includes another volume completely, set Exclude other volumes at the larger volume so that the larger volume does not overbake the results of the smaller volume.

  • Follow the bake sequence, bake the smaller volumes first, which the larger volumes include. Then, remembering to set Exclude other volumes to the larger volumes, bake the larger volumes.

Quality settings for the baking volume

The volume quality settings are set individually for each volume. Editing the quality settings will also affect only that volume.

By default there are 4 quality settings in MANU:

  • Low - intended for checking how the scene, object or several objects will look like after using lightmapping technology. In some cases you can use this quality for large objects or locations that the player is unlikely to visit. And also for low-lighted locations.

  • Medium - intended for baking more parts of scenes and objects. Use this quality to bake environments, medium and large objects, rooms and buildings.

  • High - designed to bake objects, locations and rooms that the player will have continuous and interaction with. Objects and locations that you want to focus the player's attention on and show their beauty.

  • Ultra - we recommend using this quality for the same objects that you would set the quality High, but you want to impress players with good hardware. Keep in mind that the time to bake in this quality increases significantly, as well as consumed computer resources. And greatly affects the performance of the game.

You can customize any quality setting to your needs by clicking on the Settings icon in the corner of any setting. The changed settings will be applied only for the selected quality and volume.

We do not recommend baking all objects with High quality, because it can greatly affect performance and the amount of disk resources used.

We also do not recommend beginners to customize the baking quality. Adjust only if you understand the purpose of the settings, their impact on the quality of the final result, the time spent to achieve it and the resources it may affect.

The following settings have a serious impact on quality, time and resources.

  • Bounces - the number of reflections of the tracing ray. Higher value - better quality, longer baking time.

  • Samples - number of samples for one trace beam. Higher value - better quality, longer baking time.

  • Texels per unit - number of texels (texture pixels) per one unit of game space. Higher value - better texture quality, more resources on disk. Use a value of degree 2 for this parameter .

  • Resolution - resolution of the lightmap map.Higher value - better texture quality, more resources on disk. Use a degree 2 value for this parameter.

Baking process and result

Once you have defined the settings you can click on the Bake Volume button and the baking process will start.

Depending on the quantity and complexity of the geometry of the objects to be baked, as well as the quality of baking, the baking process will take different lengths of time. Experiment and you will find the optimal ratio of quality to time.

You can cancel baking at any time by clicking the "Cancel" button in the modal progress window.

After volume baking is finished, you will immediately see the result in the scene, the baked textures will be applied to the objects included in the volume.

If some objects have not changed, check if you have set the "Bake in lightmaps" setting and if they are in the selected volume.

If some of the objects seem darker than before baking, check whether the light sources are Baked or Mixed.

If you do not like the baking results, you can reset them using the Reset Baking button.

Last updated