MayaMan Help Contents

MayaMan Custom RenderMan Shaders

Although MayaMan has the ability to use Maya's own materials through its Magic Shaders mechanism, many users will still want to be able to attach their own custom RenderMan shaders to objects in their scene. This is done using a MayaManCustomShader node. The page outlines how to use custom shaders in MayaMan.

Creating a MayaMan Custom Surface Shader Node

You create a MayaMan Shader Node just like you would create any other shader node in Maya. For example, in Maya's Hypershade, you should see a new node type under the Create->Materials section called 'MayaManCustomShader'. Simply drag a new one into the main Hypergraph window.

Modifying the Shader Node

If you select the new node and bring up the attribute editor, you will see the basic surface properties:

Update Swatch

When enabled this option will cause MayaMan to respond to each parameter modification by writing a tiny rib, using the currently selected renderer to render it and then display the result in the little swatch at the top of the Attribute Editor. Note that this can slow down interaction with parameters quite a bit and should be used sparingly.

Color / Opacity

These are the base color and opacity parameters, i.e. what will end up in the shader as 'Cs'and 'Os'.

True Displacement

This option can be used to override the value specified in the global BMRT Options dialog on a per material basis.

Pass All Texture Channels

With this option ticked, any object with this material applied will have texture coordinates placed in the rib. These texture channels are passed as a float[3] per sample where the first element is the U coordinate, the second is the V coordinate and the third indicates if the uvSet was defined at that sample. By default the channels are named, numbered and are accessed like this:
	surface foo(...,
                    varying float uvSet1[3] = {0,0,0};
                    string uvSet1Name = "";)
	{
          float S = uvSet1[0];
          float T = uvSet1[1];
          float ST_exists = uvSet1[2];

	  /* now use S/T as you would s/t */
	  ...
	}

In all cases the 0th channel (the default map channel which is a permanent fixture on maya models) is passed as s/t. Any additional channels are passed as uvSet1, uvSet2, etc. If a part of a model doesn't have a particular uvSet then it will be elided from the rib for that submodel, however, for the model as a whole the name->mapping channel number will remain constant.

Users can override the names that will be used in the rib. When a translation is first performed any polygon mesh with a custom shader attached will automatically have a string attribute created for each uvset (look for these attributes in the Extra Attributes section of the shape node, they will all have an "MM_" prefix on the uvset's name. These string attributes can be used to remap uvset names into rib names. This allows shader authors to use natural names for the uvsets according to their function and leaves the user free to associate appropriate names to the map and then be able to hook everything up.

Geom Provide N

With this option ticked, any object with this material applied will have its surface normals written into the RIB file.

Cs from Vert Cols

With this option ticked, any polygonal object with vertex color information will have that information placed into the rib as per-vertex 'Cs' data. Most regular RenderMan shader use Cs as the basic surface color of the object.... for example, using the matte surface shader will paint the surface with the vertex colors and provide basic Lambertian surface shading. Verts without explicit color assignments will receive the shader's basic surface color.

Shader File

Here you specify the name of the compiled shader file to use, or press the browse button to locate it. After selecting or entering the name of the shader file, press the 'Init' button to add all the shader's parameters to this node. The parameters will show up in the 'Extra Attributes' frame, and can be animated or driver with Maya expressions.

Assigning The Shader to Geometry

Use the Lighting/Shading->Assign Shading Group menu item in the main maya window to assign the node to your geometry.

Other Custom RenderMan Shader Types

The MayaManCustomShader node can be applied to the surface, displacement or volume connections of a shading group.

To use a custom RenderMan light shader, please read the separate help page.

Notes For Shader Authors

Lighting Models

The way maya's lights interact with the surfaces is slightly different to the traditional renderman one. If you want to modify your shaders to use maya style lighting then replace code like this:

	color amb_ill = ambient();
	color diff_ill = diffuse(Nf);
	Ci  = Cs * (Ka * amb_ill + Kd * diff_ill);
with code like this:

	color amb_ill, diff_ill;
	maya_lighting(Nf, amb_ill, diff_ill);
	Ci  = Cs * (Ka * amb_ill + Kd * diff_ill);

MayaMan Help Contents