Using and Writing Shaders

All color, displacement, contour, and other computation in mental ray is based on shaders. There are various types of shaders for different situations, such as material shaders to evaluate the material properties of a surface, light shaders to evaluate the light-emitting properties of a light source, lens shaders to specify camera properties other than the default pinhole camera, and so on.

There are external shader libraries that support compatibility with Alias, Autodesk 3ds max, Dassault Systèmes CATIA, SOFTIMAGE, SolidWorks, Wavefront, and others. Much of the power of mental ray relies on the possibility to write custom shaders and link them dynamically to mental ray at runtime. Custom shaders are written in C or C++, using the full language and library support available in these languages.

Here are the steps necessary to create a new shader:

Note that if the shader is expected to work on Windows NT, all four function definitions (the shader, the version function, and the init and exit shaders) must be preceded with DLLEXPORT. This is a pseudo type specifier that makes the functions visible to users of the generated shader library. On Unix systems DLLEXPORT evaluates to an empty word.

The shader is then ready to be used in the scene. These steps are described in detail below.

Copyright © 1986-2008 by mental images GmbH