A regular color image is created by recursively sampling the scene, that is, casting rays into the geometry. The same samples are used to generate the contours. With each sample, some user-specified information is stored by the user-specified contour store function, information that is used later for determining the locations, colors, and widths of the contours. The contour store function is called right after the material shader and saves information such as ray intersection point, the normal at the intersection point, object tag, material color, refraction level, etc.
During recursive sampling, the decision whether to take additional samples is based on the comparison of two adjacent samples. New samples are taken if the color contrast is sufficiently large (as defined by the contrast for moving objects, or if a user-specified contour contrast shader returns miTRUE. The contour contrast shader can base its decision on any information that was stored by the contour store function for the two sample points. For example, the contour contrast function could return miTRUE if their depths or orientations differ much.
When two samples are at minimum distance (according to the value of the max samples parameter), and their contour contrast is still high (that is, the contour contrast shader returns miTRUE), mental ray assumes that a contour must be drawn between the two samples and calls a user-specified contour shader. The contour shader computes the contour color and width depending on, for example, curvature (orientation difference), Z depth, Z depth difference, material color, or some other information saved by the contour store shader. The contour shader of the object closest to the camera is used. If no contour shader is specified for the material, it does not get a contour. The computed contour point data (contour color, width, etc.) for each point on the contour is stored in a temporary data structure. mental ray merges these contour points into straight contour line segments, each represented by its two endpoints.
These contour line segments are received by a contour output shader in a postprocessing step. The contour output shader reads the contour segment endpoints and generates, for example, an image or a PostScript file.
Contour rendering is not compatible with the rasterizer.
Copyright © 1986-2009 by mental images GmbH