MayaMan Help Contents

Mixing Maya Shaders and RenderMan Shading Language

MayaMan has a mechanism for blending RenderMan Shading Language (SL) and Maya shading networks, this mechanism is the SLCodeNode, a repository for SL code that can be embedded into a shading network, the magic shaders mechanism will insert your code and connect any inputs/outputs.

SLCodeNode

The SLCodeNode is a 'Utility' node. Once you have created one there are three phases to using it.

First, create inputs, use the controls in the 'Add Parameter' section to create inputs by selecting data type, parameter name and default value, then press the 'Create' button. A new value will be placed in the 'Extra Attributes' for each input. These inputs can be connected to other nodes in the same manner as any input of any maya shading node.

Second, create outputs, this procedure is the same as input creation except that you turn on the 'Output' checkbox. When an output parameter is created a declaration is added to the SL code. Due to a maya limitation output variables appear in the Extra Attributes panel, manipulating these values will have no effect on the result and they should be ignored... a good reason to create them all at once after the inputs.

Third, write the SL code. Write SL code as you normally would, don't declare any variables outside the curly braces that are automatically inserted. To refer to a input or output parameter put '$' in front of the name. The execution environment for the code will have several handy values pre-defined.... for example, for code to be used in surface or displacement shaders the PS variable contains the current point in shader space and Nf contains the normalized forward facing normal at the point (in current space) with the effect of any downstream bumping rolled in.

Add Parameter Controls

Type

The SL data type for the variable.

Name

The name for the SL parameter... use this value prefixed with a '$' in the SL Code.

Output

The parameter is something that your SL Code produces.

PrimVar

The parameter will always be have a shader arg declared, this allows the value to be overridden by the geometry. Normally if a value is an input and it's not varying the resulting shader will not have an argument for the value as the constant value will be substituted instead.

Varying

The parameter will always have a shader parameter declared and it's storage class will be varying... useful in conjunction with PrimVar.

Default

The value the parameter will have if not connected, if it's an output variable then it's the result the parameter will have if you don't compute it.

SL Code

SLInclude

If your code requires helper functions it may be a good idea to put them in a header file and put the name of the header file in here. At the moment there is no mechanism to set the include search path for the compiler so it's recommended that you either use a full path name or store your header files in the 'shaders' folder of the mayaman distribution.... the second way will make it easier for you to share code nodes with the rest of your crew.

MayaMan Help Contents