contacts and travel info home: www.mesmer.com telephone: 1.800.237.7311 : 00.1.206.782.8004

Custom Shader Basics
Custom Shader Basics Shaders tap into the rendering pipeline via data structures: one structure for receiving parameters supplied by the artist such as color selection, one structure for receiving vectors describing a ray of light and its associated color value and one structure for resulting color values that may be passed to another shader in the pipeline. Shaders do their work by examining yet another data structure for the associated geometry object. So if the object selected is a polygon mesh torus, you have access to its internals as if Mental Ray was just a strange database and XSI was its data entry front-end. (This fourth structure is accessible via library calls and referencing the structure containing input parameters.) Parameters from the XSI Property Page are passed through a shader-specific data structure. By convention, this gets a name matching your shader. Since our shader is called "constant_simple", the data structure is called "constant_simple_params". Mental Ray has its own data types for just about everything. Color values are contained within a type, "miColor". Other values are held within "miScalar". When extracting values from the primary data structures, it's important to use macros defined in "shader.h". (Find this include file within the XSI SDK; see makefile.) Apart from C/C++ code and resulting shared libraries, XSI needs to be informed about the add-on. There is an interface file that looks like a Unix shell script. Mental Ray has its ".mi" file (meaning Mental Images, the vendor of Mental Ray), and Softimage has its own file format. SPDL is Softimage Plug-in Definition Language, and the associated file extension is, oddly enough, ".spdl".

date: 2003-02-04 00:00:00 edit: Custom Shader Basics / 281 author: / 56