Baking AO maps for terrain using Blender 3D

How to bake ambient occlusion maps. It's quite simple to bake Ambient Occlusion maps (AO) using Blender, but, there are a couple of things that need to be done in order for it to work correctly and yield the best results possible. The following tutorial has been written with Blender 2.46 in mind; the only major deviation for previous versions of Blender for AO baking is that UVW maps are now done in EDIT mode (TAB) instead of FACE EDIT mode (F) as previously.

Design note : For additional details beyond the basic 'how to' please see the 'Advanced user information' section at the bottom of the tutorial.

Applying a material to the terrain mesh ^

The mesh needs a material and that material needs a filled texture slot, AO baking relies on the presence of a texture image when done in relation to game/3D content creation.

HOW TO : apply a material to the terrain mesh

Select the mesh first, then go in to the 'Shading' buttons panel (F5) and either create a new material or edit the default one that's present.

Once done add a texture image slot by clicking on the "Texture-button" button (F6) and again either add a new slot or edit the default one present (should be named "Tex" if present). Browse to the image, select and add it, it will then appear in the texture slot preview window (shown bottom left of the image below).

The raw mesh ready to be set-up for AO baking. A materials is applied with a texture slot

The raw mesh ready to be set-up for AO baking. A materials is applied with a texture slot.

Displaying the texture applied to the mesh ^

By default all the triangles of the mesh will be in what's 'reset' (shown below), this is of no use for AO baking and needs to be fixed by creating or rebuilding the UVW map so that it makes sense for the purpose of AO baking.

HOW TO : display the texture applied to the mesh (material)

To view the texture applied to the mesh in press "ALT+Z", that will switch display mode to "Textured View" (Alt+Z toggles between "Flat Shading" and "Textured" views of an object in the 3D view-port).

In "Textured" view the UVW map for the mesh is generated - UVW mapping is now done in EDIT mode

In "Textured" view the UVW map for the mesh is generated - UVW mapping is now done in EDIT mode.

UVW mapping the terrain mesh ^

Baking an ambient occlusion map relies on a good UVW map being applied to the mesh. For Blender 2.46 this is all now done from the EDIT mode.

HOW TO : uvw map the terrain mesh

Press TAB to enter EDIT mode. Once there press 'A' to select all (this may need to be done twice, once to clear isolated selected faces and then again to re-select all faces). With all faces now selected press 'U' to bring up the UVW mapping options pop-up, from here click "Unwrap" to unwrap the mesh to one single UVW map.

The result should be something similar to the image below. It's important to make sure here that the UVW map stays within the bounds of the texture space; for best results make sure there are no stray UVW vertices outside the edge of the texture.

The UVW map is created making sure that it stays within the boundary of the texture

The UVW map is created making sure that it stays within the boundary of the texture.

Baking an ambient occlusion map using the default settings ^

The default setting for ambient occlusion rendering will result is a grey scale image shaded to represent the physical characteristics of the mesh over which the textures is laid.

HOW TO : activating the ambient occlusion settings

Click on the "Shading" (F5) to activate the additional relevant material buttons. Then click on the "World Buttons" button to open up the panels associated with ambient occlusion.

In here find the panel titled "Amb Occ" and then click on the "Ambient Occlusion" button in that panel to turn on ambient occlusion; a series of button and sliders appear.

Leave everything 'as is'.

Make sure the mesh is selected (keep the mouse in the 3D view-port) and then press Ctrl+Alt+B to start the ambient occlusion rendering process.

Baking using the default settings can be done - Ctrl+Alt+B to initiate

Baking using the default settings can be done - Ctrl+Alt+B to initiate.

The rendering process will then replace and gradually update the place-holder (checker image shown above) image initially assigned to the material with the grey scale AO baked version. Depending on the complexity and density of the mesh, this shouldn't take too long. The result will be a grainy grey scale image similar to below.

Which results in a greyscale image with highlights and shadows based on the depth and height of the mesh

Which results in a grey scale image with highlights and shadows based on the depth and height of the mesh.

Colour tinting the AO baked image ^

The results of an AO bake can be colour influenced, to do so means switching to a different light influence system that effects the AO bake by using the colours assigned to the 'World' itself.

HOW TO : change the tint/colour of a baked AO map

Leave everything as it was for the previous render, except, click the button marked "Sky Colour"; nothing will change but the colour sliders in the "World" panel will now be active and influence the results of the AO baked image.

Change any of the "HoR", "HoG", "HoB" ("Horizon" RGB values) and/or the "ZeR", "ZeG", "ZeB" ("Zenith" RGB values) sliders to change the colour that will influence the subsequent AO bake.

Press Ctrl+Alt+B to restart the AO render baking process again and watch the results.

In the test render shown below the colour influence was shifted to blue which resulted in a baked AO image that had a blue tint to higher elevations. Change colours appropriately as required. This has no effect on render time.

Switching over to "Sky Color" which allows you to 'tint' the results. All other settings are left at defaults

Switching over to "Sky Color" which allows you to 'tint' the results. All other settings are left at defaults.

Quality settings for the AO baked image ^

Better quality results than those achieved using the default settings are possible by increasing the "Samples" value setting. Pre Blender 2.46 only 16 samples were available, however, 32 are now possible.

HOW TO : setting the samples value

Leave everything as is from the previous AO render and in the "Samples:" field either click on the ">" or "<" arrows, or, LMB+Hold+Drag in the "Samples:" field to increase or decrease the number of samples used in the AO bake.

Press Ctrl+Alt+B to restart the AO bake process again.

The result of increasing the samples used is a much better quality image in terms of the amount of 'noise' it produces; the higher the setting the better the quality, but, the slower the render time; using 16 or above samples results in significant amounts of time given over to the render process (relative to CPU speed).

Rendering a 'quality' AO bake means increasing the number of "Samples" - "12" give acceptable results but samples do go up to 32. The more samples the long the time required to bake the AO map

Rendering a 'quality' AO bake means increasing the number of "Samples" - "12" give acceptable results but samples do go up to 32. The more samples the long the time required to bake the AO map.

Saving the baked ambient occlusion map ^

Once the ambient occlusion map has been baked to the level of fidelity that's required it needs saving. It's best to use an image format that doesn't 'loss' compress the data in any way, so BMP, Raw TGA, TIFF are all viable alternatives; avoid using JPG wherever possible.

HOW TO : saving the final AO baked image

The resulting AO baked images needs to be saved from the "UV/Image Edit" view-port (Shift+F10 if it's not visible). Click "Image" in the view-port 'header' bar and select "Save As..."; the file browse view will open with a number of buttons and text fields.

In the header bar for this new window, look for and click on the drop-down option menu that displays an image 'type'; depending on the parent image (the image originally applied to the material and mesh) the drop down will be displaying "Targa", "Jpeg" or other 'title'.

Click and select one of the loss-less formats (tga, bmp, tiff, etc.) and then click "Save Image". The newly created baked ambient occlusion map will be saved to that location.

On saving the new AO map it will then become the active texture applied to the material and the UVW map of the mesh.

Saving the ambient occlusion map to "RAW" tga. It's best to use an uncompressed or lossless format for the resulting image when saving

Saving the ambient occlusion map to "RAW" tga. It's best to use an uncompressed or loss-less format for the resulting image when saving.

How to bake ambient occlusion maps - video ^

Baking ambient occlusion maps using Blender 3D