Adding a Formula node

The Formula node allows you to create a formula that can be applied to several nodes at the same time. For example, you create a Formula node and define two outputs - Width and Height - and link them to several generators. When you modify the formula, all linked generators use the new sizes, for example 2048 instead of 1024.

This node can have 0 to 10 input connectors and 1 and 10 output connectors. Both the input and output connector formula results are numbers.

To add a Formula node, right-click in the Graph Editor and select Create Node  > Calculation  > Formula.

Double click on the node to open its parameters:

Editing a Formula node

The parameters window allows you to add connectors and define formulas.

  • Click Add input to add an input connector. Click again to add another, and so on. 0 to 10 input connectors are permitted.

The input connectors must link to other calculation nodes

  • Click in the Input text field to change the input connector name.
  • Delete an input connector by clicking on .
  • Click in the Output text field to change the output connector name.
  • Click Add output to add an output connector. Click again to add another, and so on. 1 to 10 output connectors are permitted.
  • For each output, write a formula that represents the value of the output connector. A formula can be a simple number.


  • Delete an output connector by clicking on .

When a node is linked to the Formula node, the corresponding value in the node's properties is no longer editable. For example, if the Formula node is linked to the Coefficient of the first terrain, this parameter is grayed out in the Composition node's parameters.

Example

In the example below, the Equations formula node has two input connectors, X and Y, which take the values 400 and 150 defined by the X and Y formula nodes.

The Equations node output connectors use these X and Y values in two formulas to define the width and height of two Perlin noise generators.

The Width and Height parameters of both Perlin noise node parameters are non-editable because they are defined by the formula.

The generators are combined using a Max node, where the value of the output terrain is the maximum value of both input terrains. Here is the result:

Functions

MATHS
ABS(param) Returns the absolute value of the parameter. Example: ABS (-3) returns 3.
AVERAGE(param1; param2) Returns the average of a list of values. This function can have between 2 and 10 parameters separated by semicolons.
CLAMP(param; min; max) If param is in the range [min; max], returns param. If param is smaller than min, returns min. If param is greater than max, returns max.
Example: CLAMP (5; 10; 20) returns 10, CLAMP (15; 10; 20) returns 15 and CLAMP (25; 10; 20) returns 20.
EXP(param) Returns the exponential of param: eparam.
LERP(param1, param2, coefficient) Returns a linear interpolation between two values:
If coefficient = 0, returns param1 -
If coefficient = 1, returns param2.
When coefficient varies between 0 and 1, returns a value which varies linearly between param1 and param2, i.e. (1 - coefficient) * param1 + coefficient * param2.
LOG(param) Returns the natural logarithm of param: ln (param).
LOG10(param) Returns the decimal logarithm of param: log10 (param) = ln (param) / ln (10).
LOG2(param) Returns the binary logarithm of param: log2 (param) = ln (param) / ln (2).
MIN(param1; param2) Returns the minimum of a list of values. This function can have between 2 and 10 parameters separated by semicolons.
MAX(param1; param2) Returns the maximum of a list of values. This function can have between 2 and 10 parameters separated by semicolons.
POW(param1; param2) Returns param1 to the param2 power: param1param2.
SIGN(param) Returns 1 if param is strictly positive, -1 if param is strictly negative, 0 if param is null.
SQR(param) Returns the square of param, i.e. param * param.
SQRT(param) Returns the square root of param.
TRIGONOMETRY
SIN(angle) Returns the sine of angle expressed in radians.
SIND(angle) Returns the sine of angle expressed in degrees.
ASIN(param) Returns the arc sine of param, expressed in radians. Param value must be between -1 and 1.
ASIND(param) Returns the arc sine of param, expressed in degrees. Param value must be between -1 and 1.
COS(angle) Returns the cosine of angle expressed in radians.
COSD(angle) Returns the cosine of angle expressed in degrees.
ACOS(param) Returns the arc cosine of param, expressed in radians. Param value must be between -1 and 1.
ACOSD(param) Returns the arc cosine of param, expressed in degrees. Param value must be between -1 and 1.
TAN(angle) Returns the tangent of angle expressed in radians.
TAND(angle) Returns the arc tangent of angle expressed in degrees.
ATAN(param) Returns the arc tangent of param, expressed in radians, with a value between -PI/2 and PI/2.
ATAND(param) Returns the arc tangent of param, expressed in degrees, with a value between -90° and 90°.
ATAN2(x,y) Returns the arc tangent of y/x, expressed in radians, with a value between -PI and PI.
ATAN2D(x,y) Returns the arc tangent of y/x, expressed in degrees, with a value between -180° and 180°.
ToRadians(angle) Converts an angle from degrees to radians.
ToDegrees(angle) Converts an angle from radians to degrees.
ROUNDING
CEILING(param) Returns the smallest integer value greater than or equal to param: CEILING (1.2) returns 2, CEILING (-1.2) returns -1.
FLOOR(param) Returns the largest integer value less than or equal to param: FLOOR (1.2) returns 1, FLOOR (-1.2) returns -2.
ROUND(param) Rounds the value to the nearest integer: ROUND (1.8) returns 2, ROUND (1.2) returns 1.
TRUNC(param) Returns the integer value obtained by removing the digits after the comma: TRUNC (1.2) returns 1, TRUNC (-1.2) returns -1.
RANDOM
RAND(a ; b) Returns a random floating point number between a and b. Note: The lower bound is included (it is possible to obtain the value a, although it is extremely unlikely), and the upper bound is excluded.
RANDINT(a ; b) Returns an integer random number between a and b inclusive. Parameter b must be greater than parameter a.
CONDITIONAL
IF(test; param1; param2) Returns param1 if the test is true, param2 if the test is false.
'test' can use the following operators:
<= (less than or equal to)
>= (greater than or equal to)
< (less than)
> (greater than)
= (equal to)
<> (not equal to)
Example: IF (A < 4; 10; 20) returns 10 if A is strictly less than 4, and 20 otherwise.

Copyright © 2021 · All Rights Reserved · Wysilab