The Function suboperator performs one or more mathematical calculations on one or two input values, or operands. The suboperator provides a wide variety of functions; the specific available calculations depend on the input type or types.
Note: The output type of the Function suboperator is the more complex of the two operands. For example, a function that uses a real and an integer operand outputs real data. If you need to output a different data type, wire a Convert suboperator to the Function suboperator output.
Interface
First Operand group
The first operand is always available. The group box label ("First Operand") is followed by the label of the respective suboperator input; for example, as shown in the illustration above, it's vector input V1, and then "(X)". The latter means that the input value is substituted for X in the chosen function. For example, if Type=Integer, Use Second Operand is off, and you use the default function (in this case) of Square X*X, the input value is used as the first operand and the Function suboperator outputs its square.
- Type
- Choose the data type of the first operand. All data types supported by the Advanced Data Manipulation tools are available from the drop-down list except for Complex, Object, Pair, and Equal. This choice determines the group box label and the respective suboperator input connection type.
- Pre-Factor
- Specifies a real value by which the first operand is multiplied before the function is applied. Default=1.0.
In certain circumstances, the Pre-Factor parameter switches to one of two other parameters:
- Mix-Factor
- Available only when the Interpolation function is chosen. The Mix-Factor defines the ratio of interpolation of the two operands. For example, if the Mix-Factor is 0.5, then both inputs are considered equally. When interpolating, the sum of shares is 1.0. The Mix-Factor is the share for the first input. Since the sum is 1.0 then the share for the second input is 1.0-Mix-Factor value.
- Offset
- Available only when using a single operand (First Operand) of type Integer or Real with the Identity function. The Offset parameter is a quick way to increase or decrease the value in a data channel by a fixed amount without the hassle of creating additional suboperators.
- R3
- When on, adds the R3 input to the suboperator, to which you can connect any suboperator that outputs a real value. This input pre-factor replaces the explicit Pre-Factor value, and is multiplied by the first operand before the function is applied.
- Use Second Operand
- When on, the function uses two operands, with the result that a different set of functions is available on the Function drop-down list. When off, only the First Operand input is used.
Second Operand group
These controls are available only when Use Second Operand (see preceding) is on. In this circumstance, the Function suboperator performs calculations on two input values. Depending on the first operand type, the second operand may or may not be chosen by the user. For example, if the first operand is of the Time type, the second operand must also be of the Time type. The suboperator input connections are configured accordingly.
The group box label ("Second Operand") is followed by the label of the respective suboperator input; for example, in the illustration above, the label includes matrix input M2, and then "(Y)". The latter means that the input value is substituted for Y in the chosen function. For example, if both input types are Time and you use the function Addition X+Y, the T2 input value is added to the T1 input value.
- Type
- Choose the data type of the second operand, when appropriate. The drop-down list is available only when the first operand type is Integer, Quaternion, Real, or Vector. Otherwise, the software sets the same data type as the first operand and Type is a read-only field. The data types available from the drop-down list depend on the first operand type. For example, if the first operand type is Integer, the second can be only Integer or Real.
- Pre-Factor
- Specifies a real value by which the second operand is multiplied before the function is applied. Default=1.0.
- R4
- When on, adds the R4 input to the suboperator, to which you can connect any suboperator that outputs a real value. This input pre-factor replaces the explicit Pre-Factor value, and is multiplied by the second operand before the function is applied.
- Function
- Choose the formula used to calculate the base output value. The drop-down list contents depend on the first operand data type and second operand data type, if present. The functions are self-explanatory.
Result group
- Type
- The output data type of the Function suboperator. With a single operand and with two operands of the same type, this is always the same as the first operand data type. With two operands of different types, the output type is the more complex of the two operands. For example, a function that uses a real and an integer operand outputs real data. If you need to output a different data type, wire a Convert suboperator to the Function suboperator output.
- Post-Factor
- Specifies a value of the result type by which the result is multiplied after the function is applied. Default=1.0 or 1.
- Parameters Animation Sync
- If you animate the suboperator parameters, the software can begin applying this animation to all particles as of the start frame of the animation or the first frame of the current event, or to each particle based on its age. The options are:
- E5
- When on, you can expose the animation sync parameter via a Parameter suboperator and let the user choose. Turn on E5, add a Parameter suboperator set to Type: Animation Sync, wire it to the E5 input on the Function suboperator, and then use Expose Parameters to make the setting available in the Particle View interface.
- Restrict By Group ID
- When on, you can specify a Group ID integer data channel on which to execute the Function suboperator. Specify the data channel by clicking the Group ID Data Channel button.
This option is available only under the following conditions:
- For "All"-type functions, which appear in the Function drop-down list when Use Second Operand is off.
- For "Average"-type functions, which can appear in the Function drop-down list when using either one or two operands.
- When Restrict By Group ID is on and you've set a group ID, the specified function is executed on all particles with that group ID, but no others.
Here's an example of how this option can work:
Particle data=1 2 3 4 5 1 2 3 4 5
Function=Average: Result=3 3 3 3 3 3 3 3 3 3
Now, suppose Restrict By Group ID is on, and the data in the specified Group ID Data Channel setting=1 1 1 2 4 4 4 4 4 8
The group ID restricts how the average value will be calculated—it is for the particles with the same group ID. So, the function result will be as following (from the original particle data): 2 2 2 4 3 3 3 3 3 5
The original example had the following use case: The particles are given group IDs according to their parents: If they are spawned from the same parent then they have the same group ID. In this case, particles travel and then collide with a mesh. Once a particle collides with a mesh, all particles with the same group ID should jump to the next event.
This can be accomplished in this way: Once a particle collides, its data changes from False to True. Then OR / All Particles is used with Restrict By Group ID on. Therefore, by using OR on the same group, the True value propagates to all particles in the same group.