Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Maths utility functions

pi() real

Returns pi.

mod(real x, real y) real
mod(int x, int y) int

Returns the remainder of x / y.

sin(real x) real

Returns sin(x).

asin(real x) real

Returns sin^-1(x).

cos(real x) real

Returns cos(x).

acos(real x) real

Returns cos^-1(x).

tan(real x) real

Returns tan(x).

atan(real x) real

Returns tan^-1(x).

atan2(real y, real x) real

Returns tan^-1(y/x), mapped into the range [-pi, pi]

abs(real x) real
abs(int x) int

Returns the absolute value of x.

exp(real x) real

Returns e^x.

pow(real x, real y) real

Returns x^y.

sqrt(real x) real

Returns x^1/2.

log(real x) real

Returns the natural logarithm of x, ln(x).

floor(real x) real

Returns the largest integer y, such that x >= y.

ceil(real x) real

Returns the smallest integer y, such that x <= y.

fract(real x) real

Returns x – floor(x).

floorToInt(real x) int

Returns floor(x) converted to an integer.

ceilToInt(real x) int

Returns ceil(x) converted to an integer.

real(int x) real

Converts x to type real.

min(int x, int y) int
min(real x, real y) real
min(vec2 x, vec2 y) vec2
min(vec3 x, vec3 y) vec3

If x < y, returns x, otherwise returns y.
In the case of vec2 or vec3 arguments, the comparison is done component-wise.

max(int x, int y) int
max(real x, real y) real
max(vec2 x, vec2 y) vec2
max(vec3 x, vec3 y) vec3

If x > y, returns x, otherwise returns y.
In the case of vec2 or vec3 arguments, the comparision is done component-wise.

lerp(real x, real y, real t) real
lerp(vec2 x, vec2 y, real t) vec2
lerp(vec3 x, vec3 y, real t) vec3

Returns x * (1 – t) + y * t

clamp(int x, int minval, int maxval) int
clamp(real x, real minval, real maxval) real
clamp(vec2 x, vec2 minval, vec2 maxval) vec2.
clamp(vec3 x, vec3 minval, vec3 maxval) vec3

Returns max(minval, min(maxval, x)).
In the case of vec2 or vec3 arguments, the clamping is done component-wise.
Undefined if minval > maxval.

step(real step_x, real x) real

Returns 1 if x >= step_x, 0 otherwise.

smoothstep(real a, real b, real x) real

Returns 0 if x <= a, 1 if x >= b, and interpolates smoothly between 0 and 1 as x ranges from a to b.

smootherstep(real a, real b, real x) real

Like smoothstep but smoother.

pulse(real a, real b, real x) real

0 if x < a or x > b, 1 otherwise.

smoothPulse(real a, real b, real c, real d, real x)

0 when x < a, smoothly interpolates up to 1 when x is between a and b, 1 between b and c, smoothly interpolates down to 0 when x is between c and d. 0 when x > d.