Indigo Technical Reference

Indigo Shader Language Reference

The Indigo Shader Language (ISL) allows users of Indigo to write programs (known as shaders) that can control many aspects of Indigo, such as all material parameters. (colour, roughness, displacement etc..)

ISL is based on Winter, a high performance functional programming language.

See https://github.com/glaretechnologies/winter for Winter documentation.

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Debugging functions

print(real x) real
print(int x) int
print(bool x) bool
print(vec2 x) vec2
print(vec3 x) vec3
print(mat2x2 x) mat2x2
print(mat3x3 x) mat3x3

Prints the value of x to standard output, then returns it.

If there are multiple calls to print in a shader, the function calls are not guaranteed to execute in any particular order.

To view the standard output from Indigo, you will need to run the console version of Indigo - indigo_console. (indigo_console.exe on Windows etc..)

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.

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Matrix functions

Matrix constructors

mat2x2(real e11, real e12, real e21, real e22) mat2x2

Returns the 2 x 2 matrix
e11 e12
e21 e22

mat3x3(real e11, real e12, real e13, real e21, real e22, real e23, real e31, real e32, real e33) mat3x3
Returns the 3 x 3 matrix

e11 e12 e13
e21 e22 e23
e31 e32 e33

Matrix operations

mul(mat2x2 A, mat2x2 B) mat2x2

Returns the 2 x 2 matrix AB.

mul(mat3x3 A, mat3x3 B) mat3x3

Returns the 3 x 3 matrix AB.

mul(mat2x2 A, vec2 b) vec2

Returns the 2-vector (2 x 1 matrix) Ab.

mul(mat3x3 A, vec3 b) vec3

Returns the 3-vector (3 x 1 matrix) Ab.

transpose(mat2x2 A) mat2x2
transpose(mat3x3 A) mat3x3

Returns the transpose of A.

inverse(mat2x2 A) mat2x2
inverse(mat3x3 A) mat3x3

Returns the inverse of A. Undefined if A is not invertible.

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Miscellaneous functions

normalWS() vec3

Returns the shading normal for the current surface point in world space.

posOS() vec3

Returns the current surface point in object space coordinates.

minCosTheta() real

Returns the minimum of the cosines of the zenith angles of the incident and exitant vectors of a ray scattering off a surface.

maxCosTheta() real

Returns the maximum of the cosines of the zenith angles of the incident and exitant vectors of a ray scattering off a surface.

intrinsicCoords() vec2

Returns the intrinsic coordinates for the intersected triangle.

objectId() int

Returns a unique integer identifier for the currently hit object.

meanCurvature() real

Return the mean curvature at the current point.


Curvature shader controlling the material colour. Red = negative mean curvature, green/blue = positive mean curvature.

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Procedural noise functions

Basic noise

The basic noise function is Perlin noise, which is a pseudo-random noise function.

This is an example of Perlin noise used as a displacement value:

noise(real x) real

Returns single-valued (scalar) Perlin noise evaluated at x. Values returned lie in the range from -1 to 1.

noise(vec2 x) real

Returns single-valued Perlin noise evaluated at x.

noise(vec3 x) real

Returns single-valued Perlin noise evaluated at x.

noise3Valued(vec2 pos) vec3

Returns 3-valued noise (each component is a decorrelated noise value) evaluated at 2d-coordinates.

noise3Valued(vec3 pos) vec3

Returns 3-valued noise (each component is a decorrelated noise value) evaluated at 3d-coordinates.


An example of 3-valued noise.

noise2D4Valued(real x, real y)

Returns 4-valued noise (each component is a decorrelated noise value) evaluated at 2d-coordinates.

noise4Valued(real x, real y, real z)

Returns 4-valued noise (each component is a decorrelated noise value) evaluated at 3d-coordinates.

Basic Fractional Brownian Motion noise

This type of noise is made by adding together a number of different frequences of Perlin noise together.


FBM, 1 Octave of noise.


FBM, 2 Octaves of noise.


FBM, 3 Octaves of noise.


FBM, 10 Octaves of noise.

fbm(real x, int oc) real

Returns oc octaves of 1-D Fractional Brownian Motion noise evaluated at x.

fbm(vec2 x, int oc) real

Returns oc octaves of 2-D Fractional Brownian Motion noise evaluated at x.

fbm(vec3 x, int oc) real

Returns oc octaves of 3-D Fractional Brownian Motion noise evaluated at x.

Grid noise

gridNoise(real x) real
gridNoise(vec2 x) real
gridNoise(vec3 x) real

Takes the floor of the coordinates passed in, and then returns a quasi-random value between 0 and 1 for those integer coordinates.


Grid noise.

Voronoi noise

voronoi(vec2 p, real irregularity) vec2

Returns the coordinates of the nearest Voronoi site.
The irregularity argument controls the 'randomness' of the site positions. It should lie in the range [0, 1].
Irregularity of zero corresponds to a regular grid of site positions.
Irregularity of one corresponds to the maximum 'randomness' of cell positions within the grid, so that the grid is not visible.


A shader based on Voronoi noise. The white value of the shader is based on the distance in UV space from the shaded point to the nearest Voronoi site. Irregularity = 0.2.


A shader based on Voronoi noise. The white value of the shader is based on the distance in UV space from the shaded point to the nearest Voronoi site. Irregularity = 0.8.

voronoi3d(vec3 p, real irregularity) vec3

Similar to above, but takes a 3d vector and returns the nearest Voronoi site in 3d.

Advanced Fractional Brownian Motion Noise

fbm(int basis_type, vec3 x, real H, real lacunarity, real num_octaves) real

This fbm function is a more general fbm that takes more parameters.

basis_type selects from a number of basis noise functions:
0: Perlin basis
1: Ridged basis
2: Voronoi basis

x is a 3-vector at which the noise is evaluated.

H controls the fractal dimension: a larger value causes faster attenuation of higher frequencies.
A good default value is 1.

Lacunarity determines the gap in frequencies between different 'octaves' of noise.
A larger lacunarity means each subsequence octave will have higher frequency.
A good default value is 2.

Octaves determines the number of octaves of noise that are added together. If the value has a fractional component, the last octave is attenuated by the fractional part then added.

Basis Types


Perlin basis, 1 octave


Ridged basis, 1 octave


Voronoi basis, 1 octave

Effect of number of octaves


Perlin basis, 1 octave


Perlin basis, 2 octaves


Perlin basis, 3 octaves


Perlin basis, 10 octaves


Ridged basis, 1 octave


Ridged basis, 10 octaves


Voronoi basis, 1 octave


Voronoi basis, 10 octaves

Effect of fractal dimension (H)


Ridged basis, H=1


Ridged basis, H=1.5


Ridged basis, H=2

Effect of Lacunarity


Ridged basis, lacunarity = 3


Ridged basis, lacunarity = 4


Ridged basis, lacunarity = 6

You can download the example Indigo scene used in the images above here.

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Texture sampling functions

getTexCoords(int texcoord_set_index) vec2

Gets the i-th texture coordinates at the shading point, where i = texcoord_set_index.

sample2DTextureVec3(int texture_index, vec2 st) vec3

Samples the i-th texture defined in the current material, where i = texture_index is a 0-based index, at the normalised coordinates (s, t). Returns a (R, G, B) triplet, where each component will be in the range [0, 1].

Indigo Technical Reference > Indigo Shader Language Reference

Built-in functions – Vector functions

Vector constructors

vec2(real x, real y) vec2

Returns the 2-vector (x, y).

vec2(real x) vec2

Returns the 2-vector (x, x).

vec3(real x, real y, real z) vec3

Returns the 3-vector (x, y, z).

vec3(real x) vec3

Returns the 3-vector (x, x, x).

Vector functions

dot(vec2 a, vec2 b) real
dot(vec3 a, vec3 b) real

Returns the dot product of a and b.

cross(vec3 a, vec3 b) vec3

Returns the cross product of a and b.

length(vec2 a) real
length(vec3 a) real

Returns the length of a, ||a||.

normalise(vec3 a) vec3

Returns a / ||a||