The animation object is very similar to image, but additionally, is animated.

Its syntax can be one of:

animation <name> = <initializer>;
animation <name> = <initializer> : <modifier1, modifier2, ...>;

The available modifiers and initializers are listed below. Additional initializers may be available via extensions.

The currently drawn frame of every animation object is accessible as a 2D texture sampler with the animation's name in all GLSL functions that follow it. You can sample it like this:

glsl vec4 sampleMyAnimationFrame(vec2 position) {
    vec4 sample = texture(MyAnimation, position);
    return sample;


You can specify any subset of the following image modifiers:

  • filter(<filter mode>) – specifies the texture filtering mode. The possible values are:
    • none / nearest – nearest neighbor resampling / no filtering
    • linear – linear filtering, no mipmaps (default)
    • bilinear – linear filtering with discrete mipmap steps
    • trilinear – linear filtering with linear mipmap transitions
    • anisotropic / anisotropicN – anisotropic filtering (N×)
  • map(<X mapping>, <Y mapping>) – specifies the texture mapping / wrapping. You can also supply only one argument to be used for both dimensions. The possible values are:
    • clamp – clamps the texture coordinate to <0, 1>
    • repeat / wrap – repeats the texture outside its bounds (default)
    • mirror – repeats the texture but every other repetition is mirrored
    • clamp_to_border – uses a fixed border color out of bounds. The border color can be set as an additional argument (as a vec4 value)
  • hidden(<true / false>) – do not create a window for the animation and only use it as an intermediate output
  • resizable(<true / false>) – make the window resizable and the animation dynamically adapt to its size
  • full_range(<true / false>) – if enabled, the pixels will be stored in floating point format without clamping, allowing other shaders to sample the exact computed value at each pixel, but sacrificing some performance
  • srgb(<true / false>) – changes the animation's color space to sRGB. Sampling an sRGB image will yield a color converted to the linear color space. Additionally, for generated images, the shader's output color must also be in the linear color space. Mixing sRGB and non-sRGB images will produce erroneous results unless handled carefully
  • heavy_mode(<true / false>) – this option is required for computationally intensive shaders, where rendering time may exceed 1 second. Without it, there is a risk of GPU driver crash
  • repeat(<true / false>) – specifies whether to repeat the animation or stop at the last frame

glsl initializer

Initializes the animation as a GLSL shader output.

Its first argument is a GLSL function that will be evaluated at each pixel in each frame. This function must have two parameters, the first one being the vec2 position of the pixel between (0, 0) and (1, 1), and the second one the float current time in seconds. Its return value must be one of vec4, vec3, float, or vec2, for an RGBA, RGB, luminance, or luminance/alpha output, respectively.

The second argument specifies the dimensions of the animation. You may as well pass the width and height separately as two arguments. Use sizeof(SomeImageOrAnimation) to make the animation the same size as another object.


animation MyAnimation = glsl(animationPixel, 256, 256);

sequence initializer

Initializes the animation as an input sequence of image files. A file name template must be supplied, where the file name should contain the wildcard character * (asterisk), which represents any sequence of characters. The images will be sorted in alphabetical order. The supported image formats are identical to those in the image file initializer. The second argument is the framerate (frames per second).

Note that due to the fact that loading and displaying a large number of image files in rapid succession is a very expensive process, the program in many cases won't be able to play the animation in real time.


animation InputAnimation = sequence("frames/*.png", 25);