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: P, Vn, VLen, Nn, Ngn, Tn, s, and t; if an input is given one of these names, it will be ignored in favor of the RixShadingContext data.
The SeExpr script used to generate the pattern. Additional input connections are "late-bound" to SeExpr expression variables.RIB: string expressionDefault: ""
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 as:
Pattern "PxrTexture" "tex1" "string filename" ["checker.tx"] Pattern "PxrTexture" "tex2" "string filename" ["ratGrid.tex"] Pattern "PxrSeExpr" "mixer" "float mix" [0.5] "reference color c1" ["tex1:result"] "reference color c2" ["tex2:result"] "string expression" ["\ $c = $c1*$mix + $c2*(1-$mix); \ $c\ "]
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 LMMetal to easily create a metallic fleck paint.
res = cvoronoi(P*floatInput1) * 2 - 1; res *= floatInput2; res += Nn; res = norm(res); res
To debug an expression, we can use printf to print the value to stdout.
res = cellnoise(P); msg = printf("My result = %f %f %f",res,res,res); res