Your Ad Here

Ambient Occlusion

Ambient occlusion is a fast and computationally inexpensive way to simulate indirect illumination. It works by firing sample rays into a predefined hemispherical region above a given 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 returned for points that are unoccluded and occluded respectively. Where the object is partially occluded the bright and dark colors are mixed in accordance with the amount of occlusion.

 

In XSI, you can create an ambient occlusion effect by connecting the Ambient Occlusion shader in the render tree. This is most commonly done at the pass level to create an occlusion pass — like that seen in the image above — that can be added in and adjusted during compositing. You can also use the shader on individual objects to limit the occlusion calculation.

 

The ambient occlusion shader is used by both the RenderMap and Ultimapper tools to generate ambient occlusion maps. For details, see Generating Surface Color Maps and Transferring Maps with the Ultimapper Tool in the Texturing guide.

The Ambient Occlusion shader is also capable of reflective occlusion, which you can use to add realism to environment-mapped reflections.

The following sections describe how to use the Ambient Occlusion shader:

• For suggested ways of connecting the shader, see the next section: Connecting the Ambient Occlusion Shader

• For information about setting ambient occlusion options, see Setting Ambient Occlusion Options.

• If you want to create reflective occlusion instead of ambient occlusion, see Reflective Occlusion.

Connecting the Ambient Occlusion Shader

There are a number of ways to connect the Ambient Occlusion shader in the render tree. Some of the more commonly used ones are:

• Directly to the Material node’s surface port.

- This is often done at the partition level, using overrides, to create an ambient occlusion pass. In this case, the Ambient Occlusion shader is often the only shader used.

 

- You can also simply use the rest of an object’s render tree to drive the Ambient Occlusion shader’s bright color.

 

• To a surface shader’s Ambient port. This allows you to scale the ambient lighting contribution to an object’s surface based on where the object is occluded.

 

• Mixed with texture and/or surface shaders using a mixer shader or texture layers. This allows you to blend the occlusion effect with an object’s surface.

 

• Connected to the Material node’s Environment port. This is used when you want a reflective, rather than ambient occlusion effect. You can then drive the bright color with an environment map. See Reflective Occlusion for details.

Setting Ambient Occlusion Options

Once you connect the Ambient Occlusion shader in the render tree, you need to set its options to define how the final effect is rendered. The following sections describe how to set those options, which are all located in the Ambient Occlusion shader’s property editor.

To set the ambient occlusion options

1. Locate the shader in the render tree, and double click it to open its property editor.

2. Start with a low Number of Samples. A value of 10 or 15 is good for tuning. This parameter is described [here].

3. Set the Output Mode. The available modes are described [here].

4. Provided the output mode you chose calls for it, set the Bright Color and Dark Color. See [here] for details.

5. Set the Spread value to define the size of the sampling cone. This is described [here].

6. If desired set the Maximum Distance to limit the range of the sampling rays. See [here] for details.

7. If desired, check the Occlusion in Alpha check box to store the amount of occlusion in the alpha channel. See [here] for details.

8. Once you’ve tuned the other parameters to you satisfaction, raise the Number of Samples until you are satisfied with the occlusion effect.

Adjusting the Number of Samples

The Number of Samples parameter specifies the number of sample rays used to determine occlusion. Higher settings produce a smoother result but take longer to render. This parameter has the greatest influence over the smoothness and quality of the final occlusion effect.

 

Setting the Bright and Dark Colors

The Bright Color and Dark Color values define the colors that the shader returns for completely unoccluded and completely occluded points respectively. Usually, most sampled points are occluded to some degree, so the final color for a given point is a blend of the bright and dark colors.

These parameters can be textured to add variation to the pattern of occlusion. For example, you might drive the bright color with a sky texture to suggest clouds overhead, or drive the dark color with a dirt texture to suggest dust, especially in corners or highly detailed areas.

 

Adjusting the Spread

The Spread value defines, for each sampled point, 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 samples the entire hemisphere above the sampled point.

In terms of effect, the lower the Spread value, the more localized the occlusion effect. The higher the value, the more the effect is smoothed out.

 

As you increase the Spread value, you’ll most likely need to increase the number of samples as well. This will help eliminate speckling, especially in flat areas with little surface detail.

 

Choosing the Output Mode

The Ambient Occlusion shader has five different output modes. You can choose the desired one from the Output Mode drop-down list:

Occlusion Using Shading Normal/Occlusion Using Bent Normals: these modes both create a “standard” occlusion effect, as seen in the image below. The former mode samples the direction of the shading normal, while the latter, which is the default mode) biases the sampling direction 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 (as in the example below), the map color is multiplied with the Bright color to produce the final unoccluded color value.

 

Return Bent Normals (World Space)/Return Bent Normals (Object Space): these modes return color values based on the unoccluded world-space and camera-space normal directions respectively. In either case, the Red, Green and Blue components correspond to the X, Y and Z axes respectively.

This type of occlusion effect, rendered by itself, can be used during compositing to fine-tune lighting, for example.

 

Setting the Maximum Distance

The Maximum Distance parameter sets 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 to the specified distance. Objects outside of this range do not appear to occlude the sampled object at all. Objects within this distance occlude more the closer they are to the object.

It's normally 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.

Storing Occlusion in the Alpha Channel

Normally, the color returned for a sampled point is a blend between the Bright color and the Dark color, depending on how that point on the surface is occluded. This blend is stored in both the RGB channels and the alpha channel.

When the Occlusion in Alpha 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 value to be 1, irrespective of the occlusion, simply set the Bright color and Dark color alpha values to 1, and the blend will always return 1.

Reflective Occlusion

The Ambient Occlusion shader is also capable of reflective occlusion. When reflective occlusion is activated, the shader changes the sampling pattern in order to distribute samples around the direction of reflection, rather than the direction of the surface normal (or bent surface normal). This is most useful for adding detail to environment-only reflections created using environment maps.

You can create reflection occlusion for individual objects, but it is easiest to do it a the render pass level, as shown in the following example, where an environment map shader has been added to the current pass’ shader stack:

 

 

 

For more information about environment maps, see Using Environment Map Shaders in the Texturing guide. For more information about pass-level shaders, see Applying Shaders to Passes and Partitions in the Rendering guide.

To apply scene-wide reflective occlusion via a render pass

Before you start: this procedure assumes that the scene contains reflective objects whose surface shaders (or other reflection shaders) have their Reflection Mode parameter should be set to Environment only

For more information about reflectivity, see Reflectivity in the Material and Shader Basics guide. For more information about environment maps, see Using Environment Map Shaders in the Texturing guide.

1. Open an explorer (press 8) and press p to set the scope to passes.

2. Select the pass in which you want to create the reflective occlusion effect and press 7 to open the render tree.

3. From the render tree’s Nodes menu, get the following shaders:

- Environment > Environment

- Illumination > Ambient Occlusion

4. Connect the Ambient Occlusion shader to the Material node’s Environment Shader Stack port.

5. Connect the Environment node to the Ambient Occlusion shader’s Bright Color port.

6. Edit the Environment node’s properties to choose the image you wish to use as an environment map.

7. Edit the Ambient Occlusion node’s properties and make sure to set the following:

- Turn the Reflective parameter on.

- Reduce the Spread value to sharpen the occlusion in the object’s reflective surface.

8. Continue to tune the ambient occlusion parameters as needed. See Setting Ambient Occlusion Options for details.

To apply reflective occlusion to an object

Before you start: this procedure assumes that the object in question is reflective, meaning that it has a surface shader, or other reflection shader controlling its reflectivity. Furthermore, the surface shader’s Reflection Mode parameter should be set to Environment only.

For more information about reflectivity, see Reflectivity in the Material and Shader Basics guide. For more information about environment maps, see Using Environment Map Shaders in the Texturing guide.

1. Select the object for which you want to create the reflective occlusion effect and press 7 to open the render tree.

2. From the render tree’s Nodes menu, get the following shaders:

- Environment > Environment

- Illumination > Ambient Occlusion

3. Connect the Ambient Occlusion shader to the Material node’s Environment port.

4. Connect the Environment node to the Ambient Occlusion shader’s Bright Color port.

5. Edit the Environment node’s properties to choose the image you wish to use as an environment map.

6. Edit the Ambient Occlusion node’s properties and make sure to set the following:

- Turn the Reflective parameter on.

- Reduce the Spread value to sharpen the occlusion in the object’s reflective surface.

7. Continue to tune the ambient occlusion parameters as needed. See Setting Ambient Occlusion Options for details.

 



SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here