Sub topic 3
Baking the normal map
This chapter assumes you know Blender's object and edit modes, the Shader Editor, basic UV unwrapping, and what shading normals are.
Baking the normal map
Baking writes the surface detail of a high-poly mesh into an image. A low-poly mesh can then display that image and look detailed. A tangent-space normal map stores, for each texel, the surface direction relative to the local surface, so it works on meshes that deform.
- Apply all transforms (Ctrl+A) on both objects.
- Give the low-poly object clean UVs and a material with an empty Image Texture node.
- Select the high-poly object, then Ctrl+click the low-poly object so it is active.
- In Render Properties, set the engine to Cycles, enable Selected to Active, and set Bake Type to Normal.
- Set Cage Extrusion to about 0.02 and Max Ray Distance to 0. Click Bake.
Baking the ambient occlusion map
Use the same selection and the same Image Texture node setup. Set Bake Type to Ambient Occlusion and bake into a new image. Set that image to Non-Color, as you did for the normal map.
Applying the baked maps in a material
Connect the normal image's Color output to a Normal Map node set to Tangent space. Connect that node's Normal output to the Principled BSDF Normal input. Connect the AO image to the base color through a Multiply node to darken crevices.
OpenGL vs DirectX normal conventions
Both conventions store the same vectors, but they flip the green (Y) channel. Blender uses OpenGL. Use the DirectX convention for engines that expect it, and invert the green channel if the lighting looks reversed.
> Hmm
Diagnosing and fixing bake artifacts
- Black or missing pixels: rays missed the high-poly surface. Increase Cage Extrusion or Max Ray Distance.
- Seams: the bake bleeds too little past UV islands. Increase Margin.
- Skewed or inverted details: check UV orientation and the green channel setting.
Automating the bake with Python
import bpy
high = bpy.data.objects["Asset_high"]
low = bpy.data.objects["Asset_low"]
bake = bpy.context.scene.render.bake
bake.use_selected_to_active = True
bake.cage_extrusion = 0.02
bake.normal_space = 'TANGENT'
img = bpy.data.images.new("Asset_normal", 2048, 2048)
img.colorspace_settings.name = 'Non-Color'
nodes = low.active_material.node_tree.nodes
tex = nodes.new('ShaderNodeTexImage')
tex.image = img
nodes.active = tex
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')Alternative: baking with the Multiresolution modifier
On a single subdivided mesh, the Multires modifier can bake normal detail from its highest level down to the base level. It skips the separate high-poly object, but you still need clean UVs on the base mesh.
Exercise
Exercise
Your normal bake shows black pixels along the edges of a hard-surface part. Which setting do you change first, and why?
Show answer
Increase Cage Extrusion (or Max Ray Distance). Black pixels mean the rays missed the high-poly surface, so the cage needs to reach farther out.