Functions
Function nodes are the building blocks for more complex behavior in your Rule Editor.
Function Nodes
Break: Break Sand to its properties
Break Sand to its properties
Inputs
Outputs
Break: Break Vec2 to X and Y
Break Vec2 to X and Y
Inputs
Outputs
Break: Break Vec3 to X and Y and Z
Break Vec3 to X and Y and Z
Inputs
Outputs
Canvas: Read Average Color (3x3) At Pos
Read 3x3 Average Color at Pos from canvas image
Inputs
Outputs
Canvas: Read Color At Pos
Read Color At Pos from canvas image
Inputs
Outputs
Canvas: Read Gaussian Blur (3x3) At Pos
Read 3x3 Gaussian Blur at Pos from canvas image
Inputs
Outputs
Comment: Comment Box
Comment boxes help you document your functions
Inputs
Outputs
Comparison: Eq bool
Check if bool equals another
Inputs
Outputs
Comparison: Eq characteristic
Check if characteristic equals another
Inputs
Outputs
Comparison: Eq direction
Check if direction equals another
Inputs
Outputs
Comparison: Eq f32
Check if f32 equals another
Inputs
Outputs
Comparison: Eq i32
Check if i32 equals another
Inputs
Outputs
Comparison: Eq ivec2
Check if ivec2 equals another
Inputs
Outputs
Comparison: Eq sand
Check if sand equals another
Inputs
Outputs
Comparison: Eq sand_id
Check if sand_id equals another
Inputs
Outputs
Comparison: Eq u32
Check if u32 equals another
Inputs
Outputs
Comparison: Eq vec2
Check if vec2 equals another
Inputs
Outputs
Comparison: Eq vec3
Check if vec3 equals another
Inputs
Outputs
Comparison: Greater than f32
Check if f32 is greater than another
Inputs
Outputs
Comparison: Greater than i32
Check if i32 is greater than another
Inputs
Outputs
Comparison: Greater than u32
Check if u32 is greater than another
Inputs
Outputs
Comparison: Less than f32
Check if f32 is less than another
Inputs
Outputs
Comparison: Less than i32
Check if i32 is less than another
Inputs
Outputs
Comparison: Less than u32
Check if u32 is less than another
Inputs
Outputs
Convert: f32 To i32
Convert floating point number to integer
Inputs
Outputs
Convert: i32 To f32
Convert integer to floating point number
Inputs
Outputs
Convert: i32 To u32
Convert integer to unsigned integer
Inputs
Outputs
Convert: ivec2 To vec2
Convert integer vec2 to float vec2
Inputs
Outputs
Convert: vec2 To ivec2
Convert float vec2 to integer vec2
Inputs
Outputs
Get: Characteristic
Get characteristics of sand. Characteristics are used to define reactive behavior between types of sand. With characteristics, you can bundle functionality between multiple sand types.
Inputs
Outputs
Get: Color
Get color of sand
Inputs
Outputs
Get: Extra Bit
Get extra bit of sand, you can read the boolean value.
Inputs
Outputs
Get: Id
Get id of sand
Inputs
Outputs
Get: IsMoved
Get is_moved flag of sand. This tells whether sand was moved this frame. Useful for custom behavior
Inputs
Outputs
Get: Velocity
Get velocity of sand
Inputs
Outputs
Input: Get Arrow Key State
Get arrow key state. Use this for arrow input related behavior
Inputs
Outputs
Input: Get Canvas Size
Get size of the canvas. You can use this to apply transformations to position etc.
Inputs
Outputs
Input: Get Delta Time
Get last frame's delta time.
Inputs
Outputs
Input: Get Down
Get neighbor of input sand from down
Inputs
Outputs
Input: Get Down Left
Get neighbor of input sand from down left
Inputs
Outputs
Input: Get Down Right
Get neighbor of input sand from down right
Inputs
Outputs
Input: Get Left
Get neighbor of input sand from left
Inputs
Outputs
Input: Get Mouse Canvas Pos
Get mouse canvas position. You can use this for mouse position related behavior
Inputs
Outputs
Input: Get Position
Get position of currently inspected input sand. Each pixel represents sand on the canvas. The sand gets swapped by the simulator. This position refers to the current position of an individual sand
Inputs
Outputs
Input: Get Right
Get neighbor of input sand from right
Inputs
Outputs
Input: Get Sand
Get sand. This is the sand for which the current rule is applied.
Inputs
Outputs
Input: Get Time
Get time since app start. You can use this for time based rules.
Inputs
Outputs
Input: Get Up
Get neighbor of input sand from up
Inputs
Outputs
Input: Get Up Left
Get neighbor of input sand from up left
Inputs
Outputs
Input: Get Up Right
Get neighbor of input sand from up right
Inputs
Outputs
Logic: And
Check both input values are true
Inputs
Outputs
Logic: Characteristic Contains
Check if sand characteristic contains another characteristic
Inputs
Outputs
Logic: If, else bool
If given test is true, use first bool, else use the other bool
Inputs
Outputs
Logic: If, else direction
If given test is true, use first direction, else use the other direction
Inputs
Outputs
Logic: If, else f32
If given test is true, use first f32, else use the other f32
Inputs
Outputs
Logic: If, else i32
If given test is true, use first i32, else use the other i32
Inputs
Outputs
Logic: If, else ivec2
If given test is true, use first ivec2, else use the other ivec2
Inputs
Outputs
Logic: If, else sand
If given test is true, use first sand, else use the other sand
Inputs
Outputs
Logic: If, else sand_id
If given test is true, use first sand_id, else use the other sand_id
Inputs
Outputs
Logic: If, else u32
If given test is true, use first u32, else use the other u32
Inputs
Outputs
Logic: If, else vec2
If given test is true, use first vec2, else use the other vec2
Inputs
Outputs
Logic: If, else vec3
If given test is true, use first vec3, else use the other vec3
Inputs
Outputs
Logic: Not
Negate the boolean value
Inputs
Outputs
Logic: Or
Check at least one of input values is true
Inputs
Outputs
Math: Abs
Absolute value of the input f32
Inputs
Outputs
Math: Add: bool
Add: bool to another bool
Inputs
Outputs
Math: Add: f32
Add: f32 to another f32
Inputs
Outputs
Math: Add: i32
Add: i32 to another i32
Inputs
Outputs
Math: Add: ivec2
Add: ivec2 to another ivec2
Inputs
Outputs
Math: Add: u32
Add: u32 to another u32
Inputs
Outputs
Math: Add: vec2
Add: vec2 to another vec2
Inputs
Outputs
Math: Add: vec3
Add: vec3 to another vec3
Inputs
Outputs
Math: Atan2
Atan2 returns an angle, in radians, in the interval [-π, π] whose tangent is y / x
Inputs
Outputs
Math: Ceil
Ceil rounds up
Inputs
Outputs
Math: Clamp
Clamp a number between two other numbers
Inputs
Outputs
Math: Clamp Vec2 Length
Clamp vec2 by length
Inputs
Outputs
Math: Cos
Cosine of the input
Inputs
Outputs
Math: Cosh
Hyperbolic cosine
Inputs
Outputs
Math: Cross Vec2
Cross product of two vec2
Inputs
Outputs
Math: Cross Vec3
Cross product of two vec3
Inputs
Outputs
Math: Distance
Distance between two vec2
Inputs
Outputs
Math: Divide: bool
Divide: bool with another bool
Inputs
Outputs
Math: Divide: f32
Divide: f32 with another f32
Inputs
Outputs
Math: Divide: i32
Divide: i32 with another i32
Inputs
Outputs
Math: Divide: ivec2
Divide: ivec2 with another ivec2
Inputs
Outputs
Math: Divide: u32
Divide: u32 with another u32
Inputs
Outputs
Math: Divide: vec2
Divide: vec2 with another vec2
Inputs
Outputs
Math: Divide: vec3
Divide: vec3 with another vec3
Inputs
Outputs
Math: Dot
Dot Product of two vec2
Inputs
Outputs
Math: Exp
Exp returne e to the power of input value
Inputs
Outputs
Math: Floor
Floor rounds down
Inputs
Outputs
Math: Fract
Fractional part of a number
Inputs
Outputs
Math: Inverse Sqrt
Inverse Square Root
Inputs
Outputs
Math: Length
Length of a vec2
Inputs
Outputs
Math: Log
Natural logarithm of x. value y
which satisfies x=e^y
Inputs
Outputs
Math: Log2
Base 2 logarithm of x. value y
which satisfies x=2^y
Inputs
Outputs
Math: Max
Max of two numbers
Inputs
Outputs
Math: Min
Min of two numbers
Inputs
Outputs
Math: Mix Vec2
Mix of two vec2. Returns a * (1.0 - blend) + b * blend
Inputs
Outputs
Math: Mix Vec3
Mix of two vec3. Returns a * (1.0 - blend) + b * blend
Inputs
Outputs
Math: Multiply: bool
Multiply: bool with another bool
Inputs
Outputs
Math: Multiply: f32
Multiply: f32 with another f32
Inputs
Outputs
Math: Multiply: i32
Multiply: i32 with another i32
Inputs
Outputs
Math: Multiply: ivec2
Multiply: ivec2 with another ivec2
Inputs
Outputs
Math: Multiply: u32
Multiply: u32 with another u32
Inputs
Outputs
Math: Multiply: vec2
Multiply: vec2 with another vec2
Inputs
Outputs
Math: Multiply: vec3
Multiply: vec3 with another vec3
Inputs
Outputs
Math: Normalize Vec2
Normalize vec2
Inputs
Outputs
Math: Normalize Vec3
Normalize vec3
Inputs
Outputs
Math: Pow
A number raised to given power
Inputs
Outputs
Math: Random
A random number 0.0-1.0 seeded with current position and running time. Calling this multiple times will result with the same value within one frame. Use Random with seed (float) to use multiple random numbers for various purposes.
Inputs
Outputs
Math: Random Color
Random color (R, G, B, ranging 0.0-1.0)
Inputs
Outputs
Math: Random Direction Step
Random direction step. (Offset for: UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft, Left)
Inputs
Outputs
Math: Random Norm Dir Step Vec2
Random direction step that is normalized
Inputs
Outputs
Math: Random Range
Random between given min and max
Inputs
Outputs
Math: Random Unit Vec2
Random unit vector.
Inputs
Outputs
Math: Random with seed
Random number 0.0-1.0 seeded with position, running time, and a floating point seed offset. Change the seed offset if you want the probabilities to vary between random numbers in your graph (compared to just Random)
Inputs
Outputs
Math: Randomize Color By Range
Vary input color by given range. This can be used to vary color slightly. Do consider that colors are between 0.0 and 1.0
Inputs
Outputs
Math: Reflect
Reflection vector of a vector and given normal input
Inputs
Outputs
Math: Rotate Vec2 Radians
Rotate vec2 by input radian angle
Inputs
Outputs
Math: Round
Round number to closest integer
Inputs
Outputs
Math: Sign
Sign of a number
Inputs
Outputs
Math: Sin
Sine of the input
Inputs
Outputs
Math: Sinh
Hyperbolic sine
Inputs
Outputs
Math: Smoothstep
Smoothstep performs smooth Hermite interpolation between 0 and 1 when a < value < b. This is useful in cases where a threshold function with a smooth transition is desired.
Inputs
Outputs
Math: Sqrt
Square root of the input
Inputs
Outputs
Math: Step
Step: Outputs 0.0 if a < b, and 1.0 otherwise.
Inputs
Outputs
Math: Sub: bool
Subtract: bool from another bool
Inputs
Outputs
Math: Sub: f32
Subtract: f32 from another f32
Inputs
Outputs
Math: Sub: i32
Subtract: i32 from another i32
Inputs
Outputs
Math: Sub: ivec2
Subtract: ivec2 from another ivec2
Inputs
Outputs
Math: Sub: u32
Subtract: u32 from another u32
Inputs
Outputs
Math: Sub: vec2
Subtract: vec2 from another vec2
Inputs
Outputs
Math: Sub: vec3
Subtract: vec3 from another vec3
Inputs
Outputs
Math: Tan
Tangent of the input
Inputs
Outputs
Math: Tanh
Hyperbolic tangent
Inputs
Outputs
New: IVec2
Create new two dimensional integer vector (x, y), used for positions on canvas
Inputs
Outputs
New: Vec2
Create new two dimensional vector (x, y)
Inputs
Outputs
New: Vec3
Create new vector for colors (r, g, b)
Inputs
Outputs
New: bool
Create new bool (true, false)
Inputs
Outputs
New: f32
Create new float
Inputs
Outputs
New: i32
Create new signed integer
Inputs
Outputs
New: sand
Create new sand
Inputs
Outputs
New: sand id
Create new sand id
Inputs
Outputs
New: u32
Create new unsigned integer
Inputs
Outputs
Physics: Add Force
Write add force value at given position
Inputs
Outputs
Physics: Add Force In Radius
Write add force value within radius (clamped to 0..5.0) at given position
Inputs
Outputs
Physics: Read Add Force
Read added force value at given position
Inputs
Outputs
Physics: Read Density Pressure
Read density and pressure (output as vec2(x, y)) at given position
Inputs
Outputs
Physics: Read Force
Read force value at given position
Inputs
Outputs
Sand Utils: Check if pos neighbors another sand
Check if sand neighbors another sand with given id
Inputs
Outputs
Sand Utils: Check if sand touches another (radius considered)
Considering sand's and its neighbor's radius, check if sand touches another with given id
Inputs
Outputs
Sand Utils: Check if sand touches another characteristic
Considering sand's and its neighbor's radius, check if sand touches another sand with given characteristic
Inputs
Outputs
Sand Utils: Count 3x3 grid of sand by id
Count 3x3 grid of sand by sand id at given position
Inputs
Outputs
Sand Utils: Count Neighbors By Id
Count neighboring sands by sand id, e.g. useful in Game of Life type of rules
Inputs
Outputs
Sand Utils: Count sand circle of size by id
Count circle of given size by sand id at given position (max radius of 6)
Inputs
Outputs
Sand Utils: Count sand grid of size by id
Count grid of given size by sand id at given position (max 12). Useful for more complex Game of Life type rules
Inputs
Outputs
Sand Utils: Get Sand By Pos
Get another sand using a canvas position
Inputs
Outputs
Sand Utils: Get Step Four from Velocity
Given sand's current velocity, get its next direction step (offset) rounded to (Up, Down, Left, Right)
Inputs
Outputs
Sand Utils: Get Step from Velocity
Given sand's velocity, get its next direction step (Offset for: UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft, Left)
Inputs
Outputs
Sand Utils: Transform on touch another characteristic
Considering sand's and its neighbor's radius, determine how sand transforms based on nearby sand characteristics (touch). This function is not particularly fast, thus it is not recommended to use multiple of these.
Inputs
Outputs
Sand Utils: Transform on touch another id
Considering sand's and its neighbor's radius, determine how sand transforms based on nearby sand ids (touch). This function is not particularly fast, thus it is not recommended to use multiple of these.
Inputs
Outputs
Set: Color
Set color of sand
Inputs
Outputs
Set: Extra Bit
Set extra bit of sand, you can use this for anything. For example, initialization of sand.
Inputs
Outputs
Set: Id
Set id of sand
Inputs
Outputs
Set: Velocity
Set velocity of sand
Inputs
Outputs
Util: Dir by Offset (Step)
Given input offset ivec, return direction
Inputs
Outputs
Util: Edge Normal
Get edge normal. Edge refers to a sand bordering other than that sand. Sand is edge if it has at least one non-that-sand neighbor. The normal is the normalized negation of (3x3 mass average - center). If the mass average == center or the position is not considered edge, zero vec2 is returned
Inputs
Outputs
Util: Is Inside
Check if an ivec is inside the simulation canvas
Inputs
Outputs
Util: Offset (Step) by Dir
Given input direction, return offset ivec
Inputs
Outputs
Util: Pos at Dir
Return another position in given direction
Inputs
Outputs
Was this page helpful?