Ambient Occlusion

 
 
 

| Render Tree Usage

Category: Illumination

Shader Family: Texture

Output: Color

The Ambient Occlusion shader uses a fast and computationally inexpensive technique to simulate the effect of global illumination. It works by firing rays into a predefined hemispherical region above a given sampled point on an object's surface in order to determine the extent to which the point is blocked - or occluded - by other geometry.

Once the amount of occlusion has been determined, a bright and a dark color are used to scale the contribution of ambient light on unoccluded and occluded parts of the object surface respectively. Where the object is partially occluded the bright and dark colors are mixed in accordance with the amount of occlusion.

This shader can also be used for reflective occlusion, which is similar to ambient occlusion, but scales the contribution of a reflection map to the object's surface.

For more information about setting up ambient occlusion, see Ambient Occlusion [Indirect Illumination].

Note The ambient occlusion shader is also used by both RenderMap and Ultimapper to generate ambient occlusion maps. Make sure that ambient occlusion is enabled for the scene and keep in mind that the caching results are not captured in the ambient occlusion maps generated by these tools. For more information about using RenderMap and Ultimapper, see Specifying the Surface Map Type and Transferring Surface Attributes (Ultimapper) [Texturing].

Number of Samples

Specifies the number of sample rays used to determine occlusion. Higher settings produce a smoother result but take longer to render.

If set to 0 or a negative value then mental ray will use the global Ambient Occlusion > Rays setting in the mental ray Render Options Property Editor.

Bright Color

This color is used to scale the ambient lighting/reflection when the sampled point is completely unoccluded. If the point is partially occluded, this color is mixed with the Dark Color.

Typically, this color is set to white, but you can choose any color using the sliders. You can also drive the color using a texture.

Dark Color

This color is used to scale the ambient lighting/reflection when the sampled point is completely occluded. If the point is partially occluded, this color is mixed with the Bright Color.

Typically, this color is set to black, but you can choose any color using the sliders. You can also drive the color using a texture.

Spread

Defines the angle of the cone from which sample rays are fired. A value of 0 samples only in the direction of the surface normal, while a value of 1.0 samples the entire hemisphere above the sampled point.

Maximum Distance

Specifies the maximum range for sample rays fired from a given point.

  • When Maximum Distance set to 0 the entire scene is sampled, meaning that rays are traced until they reach the scene boundary.

  • When Maximum Distance is set to a non-zero value, sample rays are traced only for the specified distance. Objects outside of this range do not occlude the sampled object at all. Objects within this distance occlude more the closer they are to the object.

It's usually preferable to limit the maximum distance by using non-zero values. Distant objects generally affect the final result less because they occupy a proportionally much smaller area of the sampling hemisphere than closer objects of the same size. The slight reduction in overall occlusion that this may cause is offset by the accompanying reduction in render time.

Reflective

When activated, the shader performs reflection occlusion rather than ambient occlusion. This changes the sampling pattern from a cone around the surface normal to a more distributed pattern around the direction of reflection.

Using reflection occlusion can help enhance the realism of reflection maps by incorporating color and detail from the surrounding environment map.

Output Mode

The shader had five different modes that control the output color:

  • Occlusion Using Shading Normal: produces a standard ambient occlusion effect, where the Bright and Dark colors are used to scale the ambient lighting/reflection in accordance with the amount of occlusion.

In this mode, sampling is performed in the direction of the shading normal.

  • Occlusion Using Bent Normals: produces a standard ambient occlusion effect, where the Bright and Dark colors are used to scale the ambient lighting/reflection in accordance with the amount of occlusion.

In this mode, the sampling direction is biased to return more of the Bright color in the blended result.

  • Sampled Environment: is similar to regular occlusion, but also performs environment sampling. As such, when the scene uses an environment map, the map color is multiplied with the Bright color to produce the final unoccluded color value.

  • Return Bent Normals (World Space): returns a color value based on the average of the unoccluded sample rays in world space. The Red, Green, and Blue components correspond to the X, Y, and Z axes respectively.

  • Return Bent Normals (Object Space): returns a color value based on the average of the unoccluded sample rays in object space. The Red, Green, and Blue components correspond to the X, Y, and Z axes respectively.

Occlusion in Alpha

When activated, the scalar occlusion value is stored in the alpha channel, irrespective of the specified Output Mode.

Normally, the color returned for a given point is a blend between the Bright color and the Dark color, including the alpha channel, depending on how that point on the surface is occluded.

When this parameter is on, the blending between the bright and dark color is not done for the alpha channel. Instead, the alpha channel stores the actual amount of occlusion.

If you need the alpha channel to be 1, independently of the occlusion, simply set the Bright color and Dark color alpha values to 1, and the blend will always return 1.

Render Tree Usage

For standard ambient occlusion, this shader is typically connected to the Material Node's Surface input or the Ambient input of a surface shader like Phong or Lambert. For reflection occlusion, it can be connected to a surface shader's Reflection input, or to the Material node's Environment input.

For more information, see Connecting the Ambient Occlusion Shader [Indirect Illumination].

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License