### Functions

The following functions are available in your GPU scripts (case insensitive).

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Â°.
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.
COLOR
Color(r,g,b) Returns a Color type value from the 3 parameters corresponding to the 3 channels R, G and B. Each value must be between 0 and 1.
A value lower than 0 is changed into 0. A value higher that 1 is changed into 1.
Color(1,1,1) means white. Color (0,0,0) means black.
Red(color) Returns the value between 0 and 1 of the Color type parameter's red channel.
Green(color) Returns the value between 0 and 1 of the Color type parameter's green channel.
Blue(color) Returns the value between 0 and 1 of the Color type parameter's blue channel.
ColorLerp(color1, color2, coefficient) Returns a linear interpolation between two colors:
- If coefficient = 0, returns color1
- If coefficient = 1, returns color2
- When coefficient varies between 0 and 1, returns a color which varies linearly between color1 and color 2, i.e. (1 - coefficient) * color 1 + coefficient * color 2.
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.