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.”).
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
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!
Buttons allow for subtle control over
shadowing by defining a distance dependent behaviour and damping in
The row of radio buttons
the occlusion behaviour:
Add - The pixel receives light
according to the number of non-obstructed rays. The scene is lighter.
Sub - The pixel receives shadow
according to the number of obstructed rays. The scene is darker.
Both - Both effects take place,
the scene has more or less the same brightness.
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
Sky Color and
controls the light color:
Plain - The pixel receives
pure white light
according to the number of non-obstructed rays.
Sky Color - The pixel receives
colored light, the color is computed on the basis
of the portion of the sky hit by the non-obstructed rays
(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.”).
Sky Texture - A Sky Image texture
must be present, possibly an
SphereMap. It behaves as
Color but the ray color depends on the color
of the Sky texture pixel hit.
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.”).
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.