Sub topic 12
Baking the Normal Map
Assume you know basic Blender navigation, UV unwrapping, and the Shader Editor. You should already have a high-poly source object and a low-poly target object with matching proportions. The low-poly object must have a clean UV layout and an Image Texture node ready to receive the bake.
What the normal bake does
A normal map stores surface-direction information as RGB color. Each pixel describes how light should react to the low-poly surface, even though the geometry remains simple. A high-poly mesh supplies the detailed directions, and Cycles projects those directions onto the low-poly mesh's UVs.
For this chapter, use a tangent-space normal map. Tangent space follows each surface's UV orientation, so the same map can work when the low-poly object is animated or transformed.
Configure and run the bake
Select the high-poly object first, then the low-poly object last. The last selected object is active and receives the bake. Both objects must be visible and selected. Apply transforms on both objects before baking, because unapplied scale can change ray directions and produce skewed details.
In the low-poly material, create an image at the required resolution, such as 2048 × 2048. Set its color space to Non-Color. Add an Image Texture node, assign the image, and make that node active. The active Image Texture node is the bake destination.
In Cycles, enable Selected to Active. Set the normal space to Tangent. Start with a small cage extrusion, such as 0.02 Blender units. The cage expands the low-poly surface from which Cycles casts rays.
import bpy
high = bpy.data.objects["Asset_high"]
low = bpy.data.objects["Asset_low"]
scene = bpy.context.scene
scene.render.engine = "CYCLES"
scene.cycles.samples = 64
bake = scene.render.bake
bake.use_selected_to_active = True
bake.normal_space = "TANGENT"
bake.cage_extrusion = 0.02
bake.max_ray_distance = 0.0
bake.margin = 16
image = bpy.data.images.new("Asset_normal", 2048, 2048)
image.colorspace_settings.name = "Non-Color"
material = low.active_material
material.use_nodes = True
texture = material.node_tree.nodes.new("ShaderNodeTexImage")
texture.image = image
material.node_tree.nodes.active = texture
bpy.ops.object.select_all(action="DESELECT")
high.select_set(True)
low.select_set(True)
bpy.context.view_layer.objects.active = low
bpy.ops.object.bake(type="NORMAL")
image.filepath_raw = "//Asset_normal.png"
image.file_format = "PNG"
image.save()Check the result
Connect the image to a Normal Map node, set that node to Tangent space, and connect its Normal output to the Principled BSDF Normal input. Inspect the material under a strong, moving light. A flat-looking result often means the wrong image node was active or the bake was written to a different UV map.
Exercise
Which object should be active when using Selected to Active, and why?
Show answer
The low-poly object should be active because it owns the UV layout and receives the baked normal image.