fxContextLibrary

val fxContextLibrary: GlslLibrary(source)

The context of the image an effect makes, for presets that change over time or depend on the size of the image:

  • float fx_time(): the time in seconds

  • int fx_frame(): the number of the frame

  • vec2 fx_resolution(): the size of the image in pixels

  • vec2 fx_texel(): the size of a pixel in texture coordinates

A preset that reads them lists this library in the libraries of its GLSL function or parameter:

override val dynamicParameter = glslFunction<Vector2>("vec2 uv", "return uv + 0.01 * sin(fx_time()) * fx_texel();",
listOf(fxContextLibrary))

Whoever runs the shader sets the values with setFxContext, which EffectChain and the PresetFilters do on every apply. The shader code then also includes FX_CONTEXT_USE, so that the values can be set whether or not a preset reads them.