Blender Lightmap Baking Explained: Enhance Your 3D Scenes with Baked Lighting

Blender Lightmap Baking

Blender Lightmap Baking: Optimize Your 3D Models for Real-Time Rendering

Lighting Techniques Rendering Optimization Blender tutorials Blender Baked Textures Blender Tips 3D Rendering Realistic Lighting Lightmap Lightmap Baking Texturing for Games Game Development UV Mapping Efficient Lighting Game Assets Cycles Bake Real-Time Rendering CGI Workflow Baking in Blender

Principles of Lightmap Baking

Before we begin, ensure you follow these key principles:

  1. Duplicate Your Content: Always create a backup to prevent data loss.
  2. Apply Modifiers: Ensure all modifiers that alter mesh geometry, such as Subdivision, are applied.
  3. Normalize Object Scale: Check if the model's scale is set to 1.
  4. Verify Face Orientation: Ensure all normals are facing the correct direction.
  5. Set Up UV Mapping: Proper UV mapping is crucial for an accurate bake.
  6. Create and Position a Camera: This allows for previewing the final result.
  7. Use the Cycles Render Engine: Blender’s Cycles engine provides superior baking results.
  8. Set Up Materials:
    • Ensure each object has a unique material.
    • Add an Image Texture node.
    • Create a new 32-bit float image for baking.
  9. Configure Render Settings:
    • Choose the appropriate Bake Type.
    • Set View From to Active Camera.
    • Select the created Image Texture and press Bake.
  10. Save the Baked Texture: To avoid losing your work, save the generated image.

Example

Let’s follow the framework and implement it with an object

blender-lightmap-baking-example-3d-model

The scene is very simple with just one sofa model, which contains 6 individual objects

We have one Area light and one ground plane

Check the current result comparison

blender-default-result-without-lightmap-baking

On the left side the result of GLTF viewer & on the right side the result of blender cycle render

Step-by-Step Implementation

Step 1 - Duplicate and Save the Original File

Before making modifications, save a copy of the original file to avoid irreversible changes.

Step 2 - Apply Modifiers

Check if any object has active modifiers. Apply them if they affect the mesh.

blender-checking-modifiers

Let’s Apply the modifier

blender-apply-modifier

Step 3 - Normalize Scale

Select the individual object of the 3d model and on the right-side panel check if the scale is set to 1

blender-checking-if-scale-is-normalize

If the scale is not set to 1 , then Ensure the object's scale is set to 1. If not:

  • Select the object.
  • Press Ctrl + A.
  • Choose All Transforms to normalize the scale.

blender-freeze-transform-or-normalize-all-transforms

Step 4 - Verify Face Orientation

Enable Face Orientation to check if normals are correctly aligned.

blender-check-if-face-orientation-aka-normal-of-the-object-is-correct

Step 5 - Set Up UV Mapping

Go to UV Editing mode,

blender-checking-uv-map

  1. Select the model
  2. Press the tab to edit mode & Activate Face Selection
  3. Select all faces (A key).
  4. If uv is not ready or you are not satisfied with uv press u then select Smart UV

blender-creating-uv-with-smart-uv-project

If you are happy with the UV make sure to pack uv by pressing F3, searching for Pack Islands.

blender-margin-between-uv-islands

You can check your uv quality using a checker map

blender-quick-checker-map-using-textools-blender-addon

Here I used an addon called textools
\ https://github.com/franMarz/TexTools-Blender
\ If you press the Checker Map button it will add checker pattern material to the 3d model, you remove the material using the Delete button beside the Checker Map button

Step 6 - Add and Position the Camera

  1. Create a Camera.
  2. Select it and press Ctrl + 0 to set it as the active view.
  3. Adjust its position using Shift + (Backtick) and movement keys (WASD).

Step 7 - Set Render Engine to Cycles

Navigate to Render Properties and select Cycles as the Render Engine.

Step 8 - Configure Materials

  1. Ensure each object has a unique material.

blender-checking-if-same-material-is-applied-to-multiple-objects

Make sure your material is unique to every object by pressing on the number display, this will make the material unique.

Make sure to rename your material.

  1. Add an Image Texture node for every shader
  2. Create a new image (+ New), ensuring it is 32-bit float.

blender-creating-new-image-for-image-texture-material-node

Step 9 - Bake the Lightmap

  1. Navigate to Render Properties > Bake
  2. Navigate to Bake Section
  3. Set Bake Type to Combined & add other settings and press on the Bake button

blender-baking-material-instruction

Step 10 - Rendered Image

Once the render is done, the rendered image should be added to the Image Texture

blender-checking-the-result-of-bake-rendered-texture

Step 11 - Save the Image

blender-save-image-of-baked-rendered-texture

Step 12 - Apply the Baked Texture

Replace the original material with the baked texture:

  1. Connect the baked image to the Base Color input of the Principled BSDF.
  2. Adjust material properties as necessary.

blender-checking-the-baked-texture-on-the-3d-model

Adjust the setting

blender-apply-baked-texture-to-principled-bsdf

Step 13 - Export and Check Results

Export the model in GLTF format and inspect it in a GLTF Viewer to confirm the results.

checking-finale-result-of-baked-texture-to-the-gltf-viewer