Builtin functions
This page lists all builtin functions in the root namespace.
Function parameters enclosed in square brackets mean they are optional, and the function can be called without specifying that parameter.
The character used when specifying types can either mean 'any type' when it is used alone, or 'any dimension' if it is after a scalar type.
For example, float lerp(float# a, float# b, float #t) means the following overloads of lerp are available:
float lerp(float a, float b, float t); float2 lerp(float2 a, float2 b, float2 t); float3 lerp(float3 a, float3 b, float3 t); float4 lerp(float4 a, float4 b, float4 t);
Most functions on that page will appear with that notation, as they can be used with multiple types.
Interpolation
Return type |
Description |
|
|
|
|
|
|
|
|
|
|
|
Lineary blends between |
|
|
Smoothly blends between lerp(a, b, smoothstep(0, 1, t)); Or lerp(a, b, 3*t*t - 2*t*t*t); |
Random numbers
Return type |
Description |
|||||||||||||||||
|
Random function, returns a random value |
|||||||||||||||||
|
Randomly returns select(a, b, rand(0,1) < k); |
|||||||||||||||||
|
Randomly returns select(-1.0, 1.0, rand(0,1) < k); |
|||||||||||||||||
|
Random function, stands for "vector-rand", returns a random
|
Noise
Return type |
Description |
|
|
Evaluates a coherent noise field. |
|
|
Evaluates the derivative of the coherent noise field returned by |
Math functions
Return type |
Description |
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Returns Ex: |
|||
|
Remaps |
|||
|
Returns Ex: |
|||
|
Returns Ex: |
|||
|
De-linearizes the input
|
|||
|
Normalizes the input vector Ex: |
|||
|
Takes the float3suf(0, 18, 0);
float3 vec = float3(1, 2, 3); res = float3suf(vec);
|
|||
|
Useful to detect infinite or invalid values. isfinite(42); --> true isfinite(1.0/0.0); --> false isfinite(0.0/0.0); --> false This function can be used to check the return values of some functions that return infinite values as a way to report en empty result.
|
|||
|
Useful to detect infinite or invalid values. isinf(42); --> false isinf(1.0/0.0); --> true isinf(0.0/0.0); --> false This function can be used to check the return values of some functions that return infinite values as a way to report en empty result.
|
|||
|
Useful to detect infinite or invalid values. isnan(42); --> false isnan(1.0/0.0); --> false isnan(0.0/0.0); --> true |
|||
|
Reinterprets the input as a float. If given a float, does nothing. If given an int, will reinterpret its bits as if it was a float. asfloat(0x3F800000); --> 1.0 asfloat(42.0); --> 42.0 asfloat(int4(0x40490FDB, 0, 0xC0200000, -1071644672)) --> float4(3.141593, 0, -2.5, -2.5) |
|||
|
Reinterprets the input as an int. If given an int, does nothing. If given a float, will reinterpret its bits as if it was an int. asint(1.0); --> 0x3F800000 asint(42); --> 42 asint(float4(3.141593, 0, -2.5, -2.5)) --> int4(0x40490FDB, 0, 0xC0200000, 0xC0200000) |
Trigonometric functions
All trigonometric functions below are also available in the fast and accurate namespaces. fast versions are faster, but give a lower precision result. accurate versions are slower but give a higher-precision results. Functions in the root namespace without an explicit precision namespace will use the accurate namespace unless otherwise stated.
All trigonometric functions below are also available in the degrees and radians sub-namespaces, and will use the corresponding angle units. If an angle namespace isn’t explicitly specified, the functions will use degrees by default.
Return type |
Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rotation, orientation, & angles
Return type |
Description |
|
|
Returns the vector |
|
|
|
|
|
|
|
|
Combines orientations
It is useful to combine orientations coming from different sources, for example:
To create orientations, see the scene namespace. |
|
|
Inverts orientations |
Colors
Return type |
Description |
|||||||
|
|
|||||||
|
|
|||||||
|
Returns the normalized RGB chromaticity color of the emission spectrum of a blackbody at the specified temperatureThe input value should be a temperature in degrees kelvin. For example, 800 will give a red color, 3000 will give an orange/yellow color, 5000/6000 will give a white color, and higher temperatures will give a blue color. RGB colors returned are in linear space', not in sRGB space. Here’s the RGB comparison between the regular and fast versions: The two are virtually identical. Only when plotting the actual RGB curves you start seeing a difference:
|
Conditional selection
Return type |
Description |
|
|
Returns |
|
|
|
Z-order curves
Return type |
Description |
|
|
Returns the 32-bit integer morton-encoded (z-order) representation of the 2D integer vector |
|
|
Returns the 32-bit integer morton-encoded (z-order) representation of the 3D integer vector |
|
|
Returns the 2D integer vector resulting from decoding the morton-encoded (z-order) 32-bit integer value |
|
|
Returns the 3D integer vector resulting from decoding the morton-encoded (z-order) 32-bit integer value |
Derivation & integration
Return type |
Description |
|
|
Returns the analytical time-based partial derivative of |
|
|
Returns the finite-difference time-based partial derivative of |
|
|
Returns the frame-based partial derivative of |
|
|
Returns the analytical time-based integral of |
|
|
Returns the time-based integral of |











