Mental Ray Contour Shader tutorial

From TOI-Pedia
An example of the use of the contour shader[1]

To get the contour shader working you will need to follow two steps. First you need to enable the contour shader for each material you want to display contour lines. Second you need to enable and specify the way the contour is rendered.

Applying contour shader to a material

Select the ShaderGroup

The first step in using the contour shader is enabling the contour options in the material. Note that you can do this on both Maya and Mental Ray materials. To find these options you will need to access the Shader Group Node of the material. You can do this by showing the input and output connections of the material and selecting the Shader Group Node.

Enable the Contour Rendering option

In the Mental Ray > Contours section you can enable and change the Contour settings:

The color of the contour lines. This attribute can only be a color and cannot have a procedural or texture map connected to it.
The alpha (transparency) of the contour lines. If you want to see your render through the contour lines, you can specify the transparency. 0.0 = complete transparency, 1.0 = complete opaque
The width of the contour lines.
Relative Width / Absolute Width
If off, Width is specified as (fractional) number of pixels. If on, Width is specified in percents of the horizontal image resolution thus maintaining the relative contour size if the resolution changes.

Setting the Render Settings

Define the contour settings in the Render Settings
Enable Contour Rendering
Turn on or off (default) contour rendering.
Hide Source
Hides the objects that "carry" the contours
Flood Color
When Hide Source is turned on, this is the color used to flood or fill the entire frame as the background color before rendering the contour. In other words, this is the color onto which the contours caused by Hide Source are drawn.
Maya 2014 note:

In Maya 2014, you must change the default unified sampling mode in the Render Settings to the old legacy sampling fin order for Contour Rendering to work.

Go to the Quality Tab and set Sampling to Legacy Sampling Mode: Maya 2014 legacy sampling.jpg


Improves the quality by processing at N times larger than sampling down to the correct size. If this value is set to 2, the contours are processed at twice the resolution, so the quality (anti-aliasing mostly) will be approximately twice as good. Off course at the cost of render time
Filter Type
The filter type used when downsampling contours to image resolution. Where box is the shapes, most jagged one and Gaussian the smoothest.
Filter Support
The filter support as (fractional) number of pixels. The larger this value, the larger the area (in pixels)it includes, so a Gaussian Filter would become smoother.

Draw Contour Options

There are two methods to draw the contours: By property Difference or By Sample Contrast. The first lets you define the locations at which Mental Ray detects and draws contour lines based on objects, the latter based on the contrast of light and material. By combining the different options, we can

Around PolyFaces & Between Instances
Around silhouette (coverage)
Draw contour lines based on the difference between object and background.

Around all poly faces
Draw contour lines around each poly face on an object.

Around Coplanar Faces
Draw contour lines between faces with different normals. Notice that when there are no co-Planar Faces there is no contour.
Between Instances

Between Instances.jpg
Between Different Instances
Draw contour lines between different objects (instances).

Between Different Materials
Draw contour lines between objects with different materials.
Between UV Contours

Around render tessellation
Draw contour lines based on the render tessellation.

Front vs. Back Face Contours
Draw contour lines based on the normal direction of the face.

Video Tutorial

Loading the player...


  1. Image create by Sander Mulders as part of the AR0771 course


Back to Maya

Back to Lighting and rendering

Back to Mental ray rendering

Personal tools