Creating Passes with MEL

Passes


Creating passes with MEL

How to find out what kinds of passes there are
Instantiating passes 
Adding a secondary output to a pass
Listing of known channels 
How to get a list of a pass's outputs
Deleting a pass's extra outputs 
Refreshing the Attribute Editor after adding settings to a node


Creating passes with MEL

RenderMan for Maya provides controls for advanced pass manipulation. Passes can be created and modified via MEL scripting. What follows is an examination of how to manipulate passes for RenderMan for Maya using MEL scripting.  

How to find out what kinds of passes there are

RenderMan pass nodes in Maya are based on nodetype templates defined in RenderMan_for_Maya.ini. Here's what the beginning of the Shadow pass template looks like:

    nodetype pass:render:Shadow {

The part of the node type after the last colon is what will be refered to as its class. You could browse RenderMan_for_Maya.ini looking for pass classes. An easier place to look would be under the Passes tab in the render globals. If you click on the "Create Pass" button you can see an option menu containing all the known pass classes. Another easy way to get a list of pass classes is with this MEL command:

    rmanGetPassClasses;
    // Result: Custom DeepShadow EnvCube EnvMap EnvNx EnvNy EnvNz EnvPx
    EnvPy EnvPz EnvRender Final MakeGlobalDiffuse2d MakeGlobalDiffuse3d 
    Reference ReferenceImage Reflection RenderGlobalDiffuse2d
    RenderGlobalDiffuse3d SSDiffuse SSMakeBrickmap SSRender Shadow TxMake //

 

Pass Class Description
Bake A simple pass for baking arbitrary data.
BakeRender A corresponding pass for the Bake pass that turns the baked data into a texture map.
DeepShadow Renders a deep shadow.
EnvCube Makes an environment map from six input images.
EnvMap Makes an environment map from one lat-long input image.
EnvNx A subpass of EnvRender, renders a view down the negative x axis.
EnvNy A subpass of EnvRender, renders a view down the negative y axis.
EnvNz A subpass of EnvRender, renders a view down the negative z axis.
EnvPx A subpass of EnvRender, renders a view down the positive x axis.
EnvPy A subpass of EnvRender, renders a view down the positive y axis.
EnvPz A subpass of EnvRender, renders a view down the positive z axis.
EnvRender Renders six images, one down each axis, and makes an environment map out of them.
Final A final beauty render.
MakeApproxGlobalDiffuse Generates a brick map from point cloud data. Used for baking point-based approximate global illumination data.
MakeGlobalDiffuse3d Generates a brick map from point cloud data. Used for baking ray-traced global illumination data.
Reference Makes a texture map out of a ReferenceImage.
ReferenceRender Subpass of Reference that turns this image rendered by this pass into a texture map.
Reflection  
RenderApproxGlobalDiffuse A subpass of MakeApproxGlobalDiffuse that takes the global illumination data rendered by MakeApproxGlobalDiffuse and turns it into a texture map.
RenderCaustic Generates a point cloud for the creation of caustic effects.
RenderGlobalDiffuse3d A subpass of MakeGlobalDiffuse3d that takes the 3d point cloud data and makes it into a brick map.
RenderRadiosity Related to MakeApproxGlobalDiffuse, this pass generates point-based approximate global illumination data without baking said data into a brick map for reuse.
SSDiffuse A subpass of SSMakeBrickmap, this pass filters the point cloud generated by SSRender.
SSMakeBrickmap This pass converts the point cloud generated by SSDiffuse into a brick map.
SSRender This pass generates a point cloud containing subsurface scattering data.
Shadow Renders a shadow map.
TxMake Converts an input image file into a Pixar-formatted texture (.tex).

(top)


Instantiating passes

Once you know which class of pass you're interested in, instantiating it in Maya is as simple as typing the following MEL command.

Its definition looks like this:

    global proc string rmanCreatePass(string $passclass)
And here's an example:
    rmanCreatePass Shadow;
    // Result: rmanShadowPass //

Once you've created a pass you can always find it again by looking under the Passes tab of the RenderMan Settings.

(top)


Adding an secondary output to a pass

Here's the command you can use to add an extra output to a pass. Note, passes are normally instantiated with at least one output, so adding outputs is only necessary if you want extra outputs. This command creates an output node and wires it into the pass node.

    global proc string rmanAddOutput( string $passnode, string $channels )

The $channels parameter refers to the name of the output channel you're interested in.

Examples:

This causes a "specular" output to be added to all final passes.

    rmanAddOutput rmanFinalGlobals specular;
    // Result: rmanFinalOutput1 //    

This adds an output containting surface normals to a specific render pass.

    rmanAddOutput rmanFinalPass N;
    // Result: rmanFinalOutput2 //   

It's possible to put more than one channel into an output by separating channel names with commas. For example, this will generate an output containing u and v data.

    rmanAddOutput rmanFinalPass "u,v";
    // Result: rmanFinalOutput3 //   

(top)


Listing known channels

There's a command called rmanGetChannelClasses which will return a string array of the channels which are understood by the rmanAddOutput command.

Example

    rmanGetChannelClasses;
    // Result: Ci Cs N Ng Oi Os P SSAlbedo SSArea SSDMFP SSRadiance
    ambient diffuse environmentdir globaldiffuse incandescence irradiance 
    occlusion reflection refraction s shadow specular subsurface t u v
    velocity //

(top)


How to get a list of a pass's outputs

To get a list of the output nodes of a pass, use this command:

    global proc string[] rmanGetOutputs( string $passnode )

Example:

    rmanGetOutputs rmanFinalGlobals;
    // Result: rmanFinalOutputGlobals0 rmanFinalOutput1 //

(top)


Deleting a pass's extra outputs

You can get rid of a pass's extra outputs with this command:

    global proc rmanDeleteOutput( string $passnode, int $idx )

This command takes an index, where "1" is the primary output, which can't be deleted. So the index you supply should be greater than 1.

You can get also delete extra outputs by simply deleting a pass's output nodes (which are wired in to the pass).

Example:

    delete rmanFinalOutput1;

(top)


Refreshing the Attribute Editor after adding settings to a node

To cause the Attribute Editor's Extra RenderMan Attributes section to update, use this command:

    rmanUpdateAE

(top)