Card/Opacity (mip)

 
 
 

Category: Illumination

Shader Family: Surface Material

Output: Color

When doing rendering that requires no form of post production, transparency requires no special consideration: you simply add a transparency shader of some sort, and mental ray will render it correctly.

However, as soon as you begin performing post production work on the image, and rendering to multiple framebuffers, even if using mental ray's built-in depth and motion vectors framebuffers, special thought must be put into how transparency will be handled.

In general, mental ray collects its framebuffer data from the eye ray: the ray shot by the camera that hits the first object. Therefore, the z-depth, motion vector, etc. will come from this first object.

So what happens if the first object hit is completely transparent? Or maybe it is transparent in parts, such as an image of a tree mapped to a flat plane and cut out with an opacity mask, standing in front of a house? (Using flat images to represent complex objects is known as putting things on "cards", hence the name of the shader.)

When using other transparency related shaders it is most likely that even though a tree is quite correctly visible in the final rendering and you can see the house between the branches, the z-depth (and other framebuffers) will most likely contain the depth of the flat plane. For most post processing work, this is undesirable.

To solve this problem the mental ray API contains a function called mi_trace_continue which continues a ray as if the intersection with the first object hit never happened. The Card/Opacity (mip_card_opacity) shader uses this function internally, and switches between "standard" transparency and using mi_trace_continue to create a transparent object at a given threshold.

The shader's input parameter port is the color of the object.

Opacity in Alpha

When enabled, the alpha component of the input color is used as the opacity.

When disabled, the opacity parameter is used as the opacity.

Opacity

The opacity value.

Opacity is Premultiplied

When enabled, the input color is assumed to already be premultiplied with the opacity value. When disabled, the input color will be attenuated (multiplied by) the opacity value before being used.

Opacity Threshold

Sets the opacity level where the shader switches from using standard transparency to becoming "completely transparent". Generally this should be kept at 0.0, because only totally transparent pixels are treated as "not even there", but if you raises this value more and more "opaque" pixels will be considered "not there" for framebuffers. Note that the actual visible rendered result is identical, only the contents of framebuffers other than the main color framebuffer is affected by this.