Set/override node parameters using assignment expressions.
Enable/disable the operator. Disabled operators are bypassed when the operator graph is evaluated.
The set_parameter operator takes advantage of assignment expressions to set and override node parameters. An assignment expression is made up of:
The type declaration is only necessary when specifying a new user parameter, where the available types are:
bool, byte, int, uint, float, rgb, rgba, vector, vector2, string, matrix, node
Arrays are declared using square brackets, e.g.
It's not necessary to define the array size, where
float = [1 2 3] will automatically declare a float array with 3 entries.
Value and numerical operators
A value is made up of one or more operands and operators as well as optional parenthesis scoping, which together forms a numerical expression such as:
3 + 4 * 2 / (1 - 5) ^ 2 ^ 3
The supported operators work on numerical types but they can't mix types. There are two exceptions:
- Every numerical value can be multiplied/added/etc. with a single value (see division and power examples in the table below)
- Modulus only works with integer types
Apart from the standard assignment operator '=', every supported numerical operator has a corresponding assignment operator, forming the set of supported operations:
=, +=, -=, *=, /=, ^=, %=
The following parameter types are treated as literal strings and need to be scoped using single quotes or escaped double quotes:
string/string, enum/enum, node/node
This is to distinguish them from parameter references which are shown in 'Referring to other Parameters' below.
Reserved strings don't need quotes like literal strings and they supersede parameter references which are discussed in the next section.
- Boolean values are set using
- random is a test keyword which generates one or more uniform random values between 0 and 1 depending on how many values are needed for a given parameter we're assigning to, e.g.:
float a = random(produces a single random value)
rgb mix = random(produces an RGB value with 3 random numbers)
matrix m = random(produces a matrix value with 16 random numbers)
- Different ranges can be generated by multiplying the random value. To make this more useful we would need to add at least a way to control the seed.
Referring to other Parameters
Any operand in a value can refer to any parameter that exists on the node, where the rules of mixing parameters discussed above apply. If a given string is not a literal string or a reserved string we look for a parameter on the node with the given name, and substitute the value with the corresponding parameter value, e.g. imagine we have an RGB user parameter 'mix' available to us:
[1 0 0] + mix * random
A parameter can be set/overridden using a referenced parameter of the same type as the RGB example above. However, we can also set a value like an RGB using one or more referenced float parameters. For instance, let's say the node has 2 float parameters 'a' and 'b'. Then an RGB parameter can be set using e.g.:
[a 0.5 b]
We can also reference connected and linked parameters (not components) on the node we are cooking or on another node, wherein the latter case a #node_name is used, e.g.:
rgb ref_rgb = #some_shader.base_color
int ref_int = #some_node.param_node_array.some_int
matrix ref_matrix = #light.matrix
Assignment Expression Examples
In this example, we want to assign a shader used inside a Procedural (Stand-in Maya/C4D) to objects in the scene. In the Procedural, there is a shader called 'green' that works for overrides on objects inside the ass file since this green shader is in the same Procedural. The full path for the shader is used inside the Procedural for it to work for both the shapes in the ass file and the ones coming from the scene:
shader = "^/obj/arnold_procedural1/procedural^green"
You could choose a namespace for the Procedural by setting the namespace parameter on the Arnold Procedural object node in the Arnold parameters (to foo for example). Then you can use the following shader override which is more intuitive and has the same effect.
shader = "^foo^green"
Green shader from Procedural assigned to the cube in the scene