| home | << prev | next>> | contents |
Occlusion is a fast and simple method to simulate the effects of global illumination. Occlusion is the extent to which the area above a point is covered by other geometry. This is achieved by tracing a number of probe rays inside the hemispherical area above the point and testing to what extent this region is blocked.
Typical use of this shader is ambient occlusion, where the shader is used to scale the contribution of ambient lighting (which in turn may come from a diffuse environment map shader). For this use the shader should be assigned to the ambient parameters of materials like mib_illum_phong.
Another use of occlusion is reflective occlusion, where the shader is used to scale the contribution from a reflection map. For this use, the shader is generally plugged into an environment or reflection shader slot of a material, and the actual environment map image is plugged into the bright parameter. An alternative is to allow the return value of the occlusion shader to modulate the strength attribute of a reflection map shader.
A third use is to create files for external compositing, where the occlusion shader is assigned as the primary material shader on every object in the scene. The output can be used to modulate other render passes to achieve proper compositing in post-production.
The shader may also be used as a light shader. The light source must be an area light of the user type. This generates an "ambient" lightsource with built in occlusion.
color "mib_amb_occlusion" (
integer "samples" default 16,
color "bright" default 1 1 1 1,
color "dark" default 0 0 0 0,
scalar "spread" default 0.8,
scalar "max_distance" default 0,
boolean "reflective" default off,
integer "output_mode" default 0,
boolean "occlusion_in_alpha" default off
# Version 2 parameters
scalar "falloff" default 1.0,
integer "id_inclexcl" default 0,
integer "id_nonself" default 0,
)
version 2
apply texture, light
The mental ray final gathering algorithm can return the scalar occlusion value. This utitily shader simply returns this value as a grayscale result.
color "mib_fg_occlusion" (
color "result_when_fg_is_off" default 1 1 1 1
)
version 1
"Bent normal" is a term used for the average un-occluded direction vector from a surface point. For completely un-occluded surfaces this is the same as the normal vector, but for surfaces occluded by other geometry it points in the direction in which the least amount of occluding geometry is found. Bent normals are used as an acceleration technique for ambient occlusion, allowing very fast rendering that look like global illumination or final gathering lit by an environment at a small fraction of the rendering time.
Ambient occlusion as done by the mib_amb_occlusion shader (see mib_amb_occlusion) is a ray tracing technique that casts potentially large numbers of probe rays to determine to which extent a surface point is occluded. The speed of this operation depends on the number of rays (samples), the reach of the rays (max_distance) and the complexity of the scene.
When rendering an animation (or multiple views of the same scene), any object that does not move, does not change shape, or has no moving occluding object nearby will yield the same result for every frame. Therefore one can "bake" (render to a file) the ambient occlusion solution once in a first rendering pass, and re-use this result in subsequent rendering passes for any number of frames, with potentially huge performance gains. If one also "bakes" the average un-occluded direction (the bent normal) to a texture, the entire process of lighting the object based on an environment is moved to this second rendering pass, without having to trace a single ray.
By setting the output_mode parameter to 2, 3, or 4 on the ambient occlusion shader mib_amb_occlusion, bent normals are returned with the vector being encoded as a color where x is red, y is green, and z is blue. If occlusion_in_alpha is enabled, the scalar occlusion value is returned in the alpha channel. This color can be baked into a texture, for example with the help of mib_lightmap_write (mib_lightmap_write) by putting mib_amb_occlusion into its input parameter and rendering.
Once the texture file is generated, mib_bent_normal_env can be assigned to a surface shader (for example to the ambient parameter of mib_illum_phong) to look up an environment to light the object based on the baked bent normal texture, which is placed in the bent_normals parameter of mib_bent_normal_env.
This allows an extremely low-overhead simulation of global illumination-like effects for rigid objects and is especially suitable for animations. The technique does not work on deformable objects since their occlusion, shape, and normals can vary from frame to frame. For deformable objects, it is better to apply the occlusion shader directly, without baking its output.
color "mib_bent_normal_env" (
color "bent_normals" default 0 0 0 1,
boolean "occlusion_in_alpha" default on,
color "occlusion" default 1 1 1,
scalar "strength" default 0.2,
shader "environment",
integer "coordinate_space" default 2,
integer "env_samples" default 1,
scalar "samples_spread" default 0.0,
transform "matrix" default 1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
)
The coordinate space numbers match the output_mode parameter values of the ambient occlusion shader, where 2 is world space, 3 is camera space, and 4 is object space.
| home | << prev | next>> | contents |
Copyright (©) 1986-2007 by mental images GmbH