Baking Ambient Occlusion using Blender

Posted October 2nd, 2022 in game-development

Ambient occlusion is the shadow caused by the mesh itself, so for example in the corners of the mesh. Here's a sample of a crate mesh with only its ambient occlusion texture visible:

Below is the crate mesh with the same ambient occlusion texture combined with the diffuse texture:

This is normally also computed at real time in the game engine, but you may want to bake an ambient occlusion texture for the following reasons:

  • Using the ambient occlusion as a mask for something else, for example dirt
  • Exaggerating the ambient occlusion for meshes
  • Baking an ambient occlusion texture as one of the inputs for a PBR renderer

Pre-Requisites for Baking Ambient Occlusion

There is one main pre-requisite, and that is that your mesh does NOT have overlapping UVs.

If it does, and cleaning them up would be difficult, you can create a new UV map with blender, and when sampling from the ambient occlusion texture, use the second UV map. This does require a new sampler though, so may be less efficient depending on your use case.

Here's the workflow I used to create the texture with Blender:

  1. Add a Material
  2. Add a Texture
  3. Bake Ambient Occlusion
  4. Save the Texture

Add a Material

The first step is to create a material.

Ensure that "Use Nodes" is selected:

Add a Texture

Head over to the Shading tab, and add a new Image Texture to the material graph:

Click "New", and give the texture your desired dimensions:

Important: Do NOT connect the texture to anything! It must float on its own with no connections.

Bake Ambient Occlusion

Go to the "Scene" tab, and select the "Cycles" Rendering Engine:

Under the "Bake" section, select "Ambient Occlusion":

Click the "Bake" button. You may want to reduce the maximum number of samples under the "Sampling" header if it takes too long:

Save the Texture

Go to the "Rendering" tab, and select the name of the texture you created in step #2 from the dropdown box:

From the image menu, click "Save As":

That's it! Your ambient occlusion texture is ready for use.

Tagged texture ambient occlusion mesh bake material save tab select crate

Comments

Please click here to load comments.