Sub topic 2
Setting Non-Color Data and Configuring the Cycles Bake
This chapter assumes you know Blender's Object and Edit modes, the Shader Editor, and basic UV unwrapping. You should have a high-poly and a low-poly mesh, with UVs on the low-poly mesh.
Setting Non-Color data for baked maps
Normal and ambient occlusion (AO) maps store numbers, not colors. Blender treats image files as sRGB by default, which applies a gamma curve that changes the stored values. Set the bake image to Non-Color before you bake.
Cycles Bake panel overview
Set the render engine to Cycles. Open the Bake panel in Render Properties. The settings you use most are:
- Bake Type: Normal or Ambient Occlusion.
- Selected to Active: bake from one object onto another.
- Cage and Max Ray Distance: control where rays start and how far they travel.
- Margin: extends baked pixels past UV island edges.
Selected to Active: choosing source and target objects
Select the high-poly object, then ctrl-click the low-poly object so it becomes active. Blender casts rays from the low-poly surface toward the high-poly surface. The low-poly material must contain an Image Texture node that uses the bake target image, and that node must be active. Otherwise the bake has nowhere to write.
Cage, extrusion, and max ray distance
Cage extrusion pushes each ray's starting point outward along the surface normal. Use a small value such as 0.02 so the cage fully encloses the high-poly detail. Max Ray Distance limits how far a ray can travel. A value of 0 means no limit. Set a small limit if distant geometry could be hit by mistake.
Margin and padding to prevent edge bleeding
Texture filtering samples pixels near UV seams. Without padding, those samples read empty pixels and create dark or light lines along seams. Margin fills pixels past each island's edge. A margin of 16 pixels on a 2048 texture is a common starting point.
import bpy
high = bpy.data.objects["Asset_high"]
low = bpy.data.objects["Asset_low"]
scene = bpy.context.scene
scene.render.engine = 'CYCLES'
bake = scene.render.bake
bake.use_selected_to_active = True
bake.cage_extrusion = 0.02
bake.max_ray_distance = 0.0
bake.margin_type = 'ADJACENT_FACES'
bake.margin = 16
bake.normal_space = 'TANGENT'
img = bpy.data.images.new("Asset_normal", 2048, 2048)
img.colorspace_settings.name = 'Non-Color'Exercise
Exercise
Why must a normal map image be set to Non-Color before baking?
Show answer
Normal maps store vector values, not colors. Setting the image to Non-Color stops Blender from applying the sRGB gamma curve, so the stored values are preserved.