Because it is sometimes useful for an artist to be able to experiment with a procedural materials and patterns, rather than relying on painting textures or built-in nodes, PRMan includes this SeExpr node. Based on Disney Animations's open source SeExpr system, this node is a scriptable pattern generator and combiner. It is unique among the factory plugins in its "dynamic binding" capabilities. Pattern network authors can wire upstream nodes into arbitrary (named) connection points and these can be referred to in the SeExpr script.
Note that the data in the
RixShadingContext are available directly in scripts. Currently that includes:
t; if an input is given one of these names, it will be ignored in favor of the
The SeExpr script used to generate the pattern. Additional input connections are "late-bound" to SeExpr expression variables.
The three channel output if the result of the expression script is a vector.
The first channel from the resultRGB output.
The second channel from the resultRGB output.
The third channel from the resultRGB output.
If the result of the expression script is a scalar, it will be returned in this output parameter.
An SeExpr script that mixes two color textures might be written in a RIB file as:
Note that the last line of the script contains just the name of the variable that is the desired return value and does not end in a semi-colon. Also note that the name of the returned variable is not used in the connections to other nodes in the pattern network, and instead, the name used for the output connection is always one of Output Parameters mentioned above which are chosen depending on the type required.
There is only one formal input to the PxrSeExpr node, the string for the text of the expression. All other inputs are dynamic: the renderer assumes these inputs are to be used as variables in the script. Non-referenced parameters such as "mix" above will resolve to the value provided in the RI binding (here 0.5). Referenced parameters will trigger an evaluation of the pattern graph (here triggering the execution of two upstream texture nodes).
SeExpr could also be used to generate a fleck-like normal perturbation, which could be attached to the Bump Normal parameter of PxrSurface to easily create a metallic fleck paint.
Note that the above example was for the RenderMan for Maya node and there the inputs have already been named floatInput1 and so on which would appear as Float Input 1 in the Node Editor window. In this example the output name to used in the Node Editor would be resultRGB. In this case the output is not a color but the RGB output is used for any connection that needs three floats.
To debug an expression, we can use printf to print the value to stdout.