Extracting Cg Shader Code

Deprecated

mental ray will use the Cg compiler to build hardware shaders from shader graphs in Phenomena. This involves collecting and preparing the Cg code that implements the subshaders that form the Phenomenon, passing this to NVIDIA's Cg compiler, and sending the resulting assembly code to the graphics board. This process is normally invisible and automatic.

However, it is sometimes useful to extract the Cg compiler input and output for debugging purposes, or to transplant the shader into a game platform. This allows mental ray to be used as a prototyping system for shader development with the full benefit of Phenomenon construction; and then extracting the resulting hardware shaders for use in a game engine. This is done with the command-line options

    -hardware_echo "path" --
    -hardware_echo error "path" --

The first variant saves all shaders into the directory path; the second saves only those shaders for which the Cg compiler has reported an error. The latter mode is intended for debugging by shader authors. Saving a shader means creating four files per material that uses a Cg hardware shader:

Note that the file names are constructed from the name of the material containing the hardware shaders, not from the name of a shader, because many shaders are usually collected to build a Cg input file, and because two materials using the same shader with different parameters will result in different Cg files.

Copyright © 1986-2010 by mental images GmbH