Mode: All modes
Panel: Amb Occ (Shading Context, World sub-context, F8)
Ambient Occlusion is a sophisticated raytracing calculation which simulates soft global illumination by faking darkness perceived in corners and at mesh intersections, creases, and cracks, where light is diffused (usually) by accumulated dirt and dust. This has the effect of darkening cracks, corners and points of contact, which is why ambient occlusion is often referred to as a “dirt shader”.
There is no such thing as AO in real life, AO is a specific not-physically-accurate (but generally nice looking) rendering trick. It basically samples a hemisphere around each point on the face, sees what proportion of that hemisphere is occluded by other geometry, and shades the pixel accordingly. It’s got nothing to do with light at all, it’s purely a rendering trick that tends to look nice because generally in real life surfaces that are close together (like small cracks) will be darker than surfaces that don’t have anything in front of them, because of shadows, dirt, etc. The AO process though is approximating this result, it’s not simulating light bouncing around or going through things. That’s why AO still works when you don’t have any lights in the scene, and it’s why just switching on AO alone is a very bad way of “lighting” a scene.
You must have raytracing enabled as a Render panel option (Scene context, F10, Render sub-context) for this to work.
You must have an ambient light color (Shading context, World sub-context, F8, AmbRGB sliders) set to your desires. By default, the ambient light color (world) is black, simulating midnight in the basement during a power outage. Applying that color as ambient will actually darken all colors. A good outdoor mid-day color is RGB (0.9, 0.9, 0.8) which is a whitish yellow sunny kind of color on a bright-but-not-harshly-bright day.
Ambient occlusion has evolved a bit in Blender 2.49. You have now two main methods: Raytrace and Approximate. For those who knew the tool in previous versions (2.48 and below), they will find nearly the same options (with the same behavior) using the Raytrace method, Constant Jittered sample generator.
The Raytrace method gives the more accurate, but also the more noisy results. You can get a nearly noiseless image, but at the cost of render time… It is the only option if you want to use the colors of your sky’s texture.
You have the three standard sample options:
- Constant QMC
- The base Quasi-Monte Carlo, gives evenly and randomly distributed rays.
- Adaptive QMC
- An improved version of QMC, that tries to determine when sample can be lowered or skipped, based on its two settings:
- The limit below which the sample is considered fully occluded (“black”) or un-occluded (“white”), and skipped.
- Adapt Vec
- A factor to reduce AO sampling on fast moving pixels. As it uses the Vec render pass, this one must be enabled (see render passes page).
See also the raytraced shadows page for more info about Qausi-Monte Carlo sampling method.
- Constant Jittered
- The historical sample method, more prone to “bias” artifacts…
- The angle (in radians) the hemisphere will be made narrower (i.e. the hemisphere will be no more a real hemisphere: its section will be no more a semicircle, but an arc of a circle of “
pi - Bias” radians).
- The bias setting allows you to control how smooth “smooth” faces will appear in AO rendering. 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. Note that even if it might happens with QMC sampling methods, this is much more visible with the Constant Jittered one – and anyway, you have no Bias option for QMC…
- The number of rays used to detect if an object is occluded. Higher numbers of samples give smoother and more accurate results, at the expense of slower render times. 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 at 5 means 25 rays). Rays are shot at the hemisphere according to a random pattern (determined by the sample methods described above), this causes differences in the occlusion pattern of neighboring pixels unless the number of shot rays is big enough to produce good statistical data.
- Max Dist (formerly Dist)
- The length of the occlusion rays. The longer this distance, the greater impact that far away geometry will have on the occlusion effect. A high Max Dist value also means that the renderer has to search a greater area for geometry that occludes, so render time can be optimized by making this distance as short as possible, for the visual effect that you want.
The Approximate method gives a much smoother result for the same amount of render time, but as its name states, it is only an approximation of the Raytrace method, which implies it might produce some artifacts – and it cannot use the sky’s texture as base colors…
I don’t know how it works precisely, so if anybody does, please write here a small description of the algorithm…
- This is the tolerance factor for approximation error (i.e. the max allowed difference between approximated result and fully computed result). The lower, the slower the render, but the more accurate the results… Ranges between 0.0 and 10.0, defaults to 0.250.
- Pixel Cache
- When enabled, it will keep values of computed pixels, to interpolate it in its neighbors. This speeds up further more the render, generally without visible loss in quality…
This method seems to tend to “over-occlude” the results. You have two complementary options to reduce this problem:
- Set the number of pre-processing passes, between 0 (no pre-processing) to 10. Don’t know what this pre-processing does, though…
- A correction factor to reduce over-occlusion. Ranges between 0.0 (no correction) to 1.0.
- Use Falloff (formerly Use Distance
- When activated, the distance to the occluding objects will influence the “deepness” of the shadow. This means that the farer away is an occluding geometry, the lighter will be its “shadow”. This effect only occurs when the Strength factor is higher than 0.0. It mimics the light dispersion in the atmosphere…
- Stength (formerly DistF)
- Controls the attenuation of the shadows enabled with Use Falloff. Higher values give a shorter shadow, as it falls off more quickly (corresponding to a more foggy/dusty atmosphere). Ranges from 0.0 (default, no falloff) to 10.0.
The ambient occlusion pass is composited during the render pipeline. Three blending modes are available:
- The pixel receives light according to the number of non-obstructed rays. The scene is lighter.
- The pixel receives shadow (negative light) according to the number of obstructed rays. The scene is darker.
- Both effects take place, the scene has more or less the same brightness, but more contrast.
- The strength of the AO effect, a multiplier for addition or subtraction.
If Sub is chosen, there must be other light sources, otherwise the scene will be pitch black. In the other two cases the scene is lit even if no explicit light is present, just from the AO effect. Although many people like to use AO alone as a quick shortcut to light a scene, the results it gives will be muted and flat, like an overcast day. In most cases, it is best to light a scene properly with Blender’s standard lamps, then use AO on top of that, set to “Sub”, for the additional details and contact shadows.
Ambient occlusion can take the color of its lighting from various sources:
- The pixel receives shading based on the world’s ambient color.
- Sky Color
- The pixel receives shading based on the world’s sky color. The color is computed on the basis of the portion of the sky hit by the non-obstructed rays (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 AngMap or a SphereMap. It behaves as Sky Color, but the ray color depends on the color of the sky texture pixel hit (only available with the Raytrace method).
Ambient occlusion is calculated 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 is a raytracing technique (at least with Raytrace method), so it tends to be slow. Furthermore, performance severely depends on octree size, see the rendering chapter for more information.