Sub topic 3
What an Ambient Occlusion Map Stores
This chapter assumes you know basic Blender navigation, how materials and the Shader Editor work, and what shading normals are. You do not need to have baked anything yet. The goal here is a working model of what an ambient occlusion (AO) map contains, so the later bake chapters make sense.
The idea: how much of the sky can a point see?
Ambient occlusion is a measure of how exposed a surface point is to ambient light. Imagine standing on a surface point and looking at the hemisphere above it. If nothing blocks your view, the point is fully exposed. If a wall, crease, or neighboring part blocks much of that view, the point is occluded and receives less ambient light.
An AO map stores that exposure as one number per texel (a pixel of a texture):
- White (1.0) means fully exposed.
- Black (0.0) means fully blocked.
- Gray values mean partial blocking, such as the inside of a shallow groove.
Because it is a single value per texel, the map is grayscale. Blender writes it into an RGB image, but the red, green, and blue channels hold the same number.
How Blender computes it
Cycles estimates AO by tracing rays. For each texel, Blender finds the matching point on the surface and shoots rays into the hemisphere around that point's normal. Each ray either escapes or hits geometry. The stored value is roughly the fraction of rays that escape.
Two consequences follow from this model:
- Noise depends on sample count. Few rays per texel give a grainy map. More samples smooth it out. The scripts later in this tutorial use
scene.cycles.samples = 64, which is a reasonable starting point for AO and can be raised if you see grain. - The result depends on what geometry is in the scene. AO is not a property of the low-poly mesh alone. It depends on whatever can block the rays.
What the baked AO map encodes in a high-to-low bake
In a Selected to Active bake, Blender casts rays from the low-poly surface to find the matching point on the high-poly surface. The AO is then computed from the high-poly geometry. The map therefore stores the shadowing of the detailed sculpt, but laid out on the low-poly UV layout.
This is the point of baking AO. The low-poly mesh has few polygons, so it cannot show small crevices, panel gaps, or the dark area under a bolt head. The high-poly mesh has all of those. The baked map carries that crevice darkening onto the cheap mesh as a texture.
| Feature in the high-poly mesh | What the AO map shows |
|---|---|
| Deep groove or panel gap | Dark line |
| Inside corner where two surfaces meet | Soft dark gradient |
| Flat, open surface | White or near white |
| Raised rivet or bolt head | White top, dark ring around its base |
| Surface close to a neighboring part | Darkening where the parts nearly touch |
AO compared with a normal map
Chapter readers often confuse the two maps, so it helps to separate them.
| Property | Normal map | AO map |
|---|---|---|
| What it stores | Surface direction, as an RGB vector per texel | Exposure to ambient light, as one gray value |
| Effect on rendering | Changes how light bends across the surface | Darkens ambient light in crevices |
| Channels | Three channels with distinct meaning | One value, copied into three channels |
| Color space | Non-Color | Non-Color |
| Silhouette | Does not change it | Does not change it |
Neither map changes the mesh shape. A normal map fakes the shading of small bumps. An AO map fakes the soft shadows that those bumps would cast on themselves. They are complementary, and many pipelines bake both from the same high-poly source.
AO is baked light, so it can be wrong later
An AO map is a fixed picture. Once baked, it does not react to the scene. This matters in three ways:
- It does not follow moving parts. If a door on the model opens, the baked darkness around the closed door stays where it was.
- It ignores other objects. If you bake the asset alone, the map cannot know that the asset will later sit next to a wall. Real-time engines usually add their own screen-space or baked occlusion for that.
- It can double-darken. If the render engine already computes its own ambient occlusion and you also multiply the baked map, creases get darker than they should. Decide which source you rely on.
Which geometry blocks the rays
The set of objects that can block rays decides the result, so it is worth knowing before you bake. In a Selected to Active bake, the high-poly object is the source. Blender computes occlusion from the source geometry that the rays reach. Anything else visible to the ray tracer in the scene may also affect the result, such as a floor plane or another asset. If your AO map has unexplained dark patches, check for stray objects before suspecting the settings.
Back-facing and overlapping geometry also matter. Faces inside a closed mesh can darken nearby texels, and floating parts that sit inside the main body can produce dark blotches. Clean the high-poly mesh as described in the mesh preparation chapter.
How the map is used later
You usually bring the baked AO into a material in one of two ways:
- Multiply it over the base color. This darkens crevices in the color texture. It is simple and works in any engine.
- Plug it into an engine's dedicated AO input. Many real-time engines have an occlusion slot that only affects ambient lighting, which is more accurate than baking the darkness into the color.
The second option is usually better for a physically plausible result, because it leaves direct light unaffected. The first option is acceptable for stylized work or when the target engine has no AO slot.
Here is the minimal script for the baking step itself. It reuses the Selected to Active setup, creates a Non-Color image, and bakes AO into it. It assumes the objects Asset_high and Asset_low exist and that the low-poly mesh already has a material and a UV map.
import bpy
high = bpy.data.objects["Asset_high"]
low = bpy.data.objects["Asset_low"]
img = bpy.data.images.new("Asset_ao", 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.context.scene.render.bake.use_selected_to_active = True
bpy.ops.object.bake(type='AO')
img.filepath_raw = "//Asset_ao.png"
img.file_format = 'PNG'
img.save()The image is set to Non-Color because it holds measured data, not a picture meant for display. Blender should not apply a display transform to it. The color space chapter covers this in detail.
Common misunderstandings
- "AO adds shape." It does not. Only the shading changes, and the silhouette stays that of the low-poly mesh.
- "White means no data." White means fully exposed. A large white area on a flat surface is correct.
- "A very dark map means a good bake." Heavy black usually points to ray hits from the wrong geometry, such as overlapping shells, or to a distance setting that is too large for the model.
- "The AO map has color." It has no hue. If you see colored areas, you baked a different pass.
Exercise
You bake an AO map from a high-poly door that has a deep panel groove. Later you animate the door opening in the low-poly asset. Which parts of the baked map stay valid, which become wrong, and why?
Show answer
The darkening inside the panel groove stays valid, because it comes from the door's own fixed geometry and moves with the door's UVs. The darkening that came from the door sitting in its frame becomes wrong once the door opens, because the AO map is a fixed image of the closed-door lighting situation and does not update when objects move.
Exercise
An AO map baked from a bolt-covered panel shows a white bolt top, a dark ring around each bolt base, and a white flat panel. Explain each tone in terms of the rays used to compute it.
Show answer
On the bolt top and the flat panel, almost every ray in the hemisphere escapes, so the value is near 1.0 (white). At the base of a bolt, the bolt's side blocks many rays, so fewer escape and the value drops toward black, giving the dark ring.