Ambient Occlusion

Ambient Occlusion is a sophisticated ambient trick which simulates soft global illumination by taking into account the amount of sky (which is assumed to be the lightsource) seen by a given point.

This is actually done by casting rays from each visible point, and by counting how many of them actually reach the sky, and how many, on the other hand, are obstructed by objects. The amount of light on the point is then proportional to the number of rays which have 'escaped' and have reached the sky.

This is done by firing a hemisphere of shadow-rays around. If a ray hits another face (it is occluded) then that ray is considered 'shadow', otherwise it is considered 'light'. The ratio between 'shadow' and 'light' rays defines how bright a given pixel is.

Ambient Occlusion (AO) settings are in the Shading Context, World Buttons Sub-context, in the Amb Occ Tab. AO is Off by default, if it is turned On, the Tab is populated by many buttons (Figure 13.11, “Ambient Occlusion Panel.”).

Figure 13.11. Ambient Occlusion Panel.

Ambient Occlusion Panel.

Rays are shot at the hemisphere according to a random pattern, this causes sensible differences in the occlusion pattern of neighbouring pixels unless the number of shot rays is big enough to produce good statistical data. This is why AO produces a granular pattern, which looks like dirt, if there are not enough rays. The number of shot rays is controlled via the Samples NumButton. The default value of 5 is usually good for previews. The actual amount of shot rays is the square of this number. (i.e. Samples=5 means 25 rays). Figure 13.12, “Effect of the different number of samples.” shows a simple scene, with increasing number of samples. Of course rendering time increases as the number of samples increases!

Figure 13.12. Effect of the different number of samples.

Effect of the different number of samples.

The Dist and Use Distances Buttons allow for subtle control over shadowing by defining a distance dependent behaviour and damping in the occlusion.

The row of radio buttons Add, Sub and Both controls the occlusion behaviour:


If Sub is chosen then there must be some light source somewhere, otherwise the scene would be pitch black. In the other two cases the scene is lit even if no explicit light is present.

The row of radio buttons Plain, Sky Color and Sky Texture controls the light color:

Figure 13.13. Ambient Occlusion with Sky Color. Zenith is blue, Horizon is orange, and type is Blend so that sky goes full orange at Nadir.

Ambient Occlusion with Sky Color. Zenith is blue, Horizon is orange, and type is Blend so that sky goes full orange at Nadir.

The Energy slider controls the actual amount of light/shadows the AO procedure creates.

Since AO occurs on the original faceted mesh, it is possible that the AO light makes faces visible even on objects with 'smooth' On. This is due to the way AO rays are shot, and can be controlled with the Bias Slider. The bias setting allows you to control how smooth 'smooth' faces will appear in AO rendering. The bias denotes the angle (in radians) the hemisphere will be made narrower. Values of 0.05 to 0.1 typically work well (Figure 13.14, “Ambient Occlusion bias values.”).

Figure 13.14. Ambient Occlusion bias values.

Ambient Occlusion bias values.

Please note that this is just raytracing, so it tends to be slow. Furthermore, performance severely depends on Octree size, see the Rendering Chapter for more information.