mib_bent_normal_env

 
 
 

Category: mental ray > Texture

Shader Family: Texture

Output: Color

"Bent normal" is a term used for the average unoccluded direction vector from a surface point. For completely unoccluded surfaces, this is the same as the normal vector, but for surfaces occluded by other geometry, this 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 for rendering that looks like global illumination or final gathering lit by an environment, but at a small fraction of the rendering time.

Ambient occlusion as done by the mib_amb_occlusion shader is a raytracing 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 yields the same result for every frame. Therefore, you can "bake" (render to a file) the ambient occlusion solution once in a first rendering pass, and then reuse this result in subsequent rendering passes for any number of frames, with potentially huge performance gains. If you also bake the average unoccluded 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 mib_amb_occlusion shader, 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, such as by connecting mib_amb_occlusion shader to the mib_lightmap_write's input parameter and then rendering it.

Once the texture file is generated, you can assign the mib_bent_normal_env shader to a surface shader, such as 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 connected to the bent_normals parameter in the mib_bent_normal_env shader.

This allows for a very "low-cost" 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.

Name

The name of the shader node displayed in the render tree. Enter any name you like, or leave the default.

bent_normals

The bent normal data output by the occlusion shader. It should be baked to the object. This is usually attached to a node that does the texture lookup, such as mib_texture_lookup. The texture mapping used for generating the texture must match with the one used for lookup.

occlusion_in_alpha

Specifies whether the scalar occlusion value is already baked into the alpha channel of the "bent normals" pass. This uses slightly less memory, but many "bake to texture" functions of software integrations of mental ray do not bake the alpha channel.

occlusion

The separate occlusion channel to be used if it was not already baked into the alpha channel.

strength

A simple scalar multiplier for the effect.

environment

The environment shader to look up. If none is provided, the environment from the material is used. To avoid image noise, you may want to use a separate, highly-blurred environment map with no high-resolution detail.

coordinate_space

Defines the coordinate space of the bent normal:

  • 0 is unmodified. The bent normal data is in internal space.

  • 1 is "by matrix". The bent normal data is transformed with the passed transformation matrix.

  • 2 is world space.

  • 3 is camera space.

  • 4 is object space. This is often the most useful mode. If the map is both created and used in object space, it automatically follows the object as it moves through an animation.

The coordinate space numbers match the output_mode parameter values of the mib_amb_occlusion shader, where 2 is world space, 3 is camera space, and 4 is object space.

env_samples

The number of samples to take from the environment map. Normally, a highly-blurred environment map is used where only one sample is sufficient, but you can multi-sample the environment map by setting a non-zero value.

samples_spread

The spread factor for each individual environment sample. The range is from 0.0 (infinitely thin rays — a single sample) to 1.0 (the entire hemisphere is sampled).

matrix

An explicit transformation matrix applied to the normal data when the coordinate_space value is 1. This allows arbitrary transformations.