API Reference

Uniforms

ShaderPad initializes the following built-in uniforms for every instance. Declare only the ones your GLSL actually uses; the rest will be ignored, so performance is unaffected.

Built-in Uniforms

NameTypeInitial valueUpdate timingNotes
u_timefloat0.0Updated by play() and step() before each rendered frameElapsed time in seconds from the current start time. draw() does not advance it.
u_frameint0Updated by play() and step() before each rendered frameCurrent frame index. draw() does not advance it.
u_resolutionvec2current drawing buffer sizeInitialized during setup and updated whenever the drawing buffer changes sizeValues are in pixels.
u_cursorvec2[0.5, 0.5]Updated on mouse or touch movement on canvas or cursorTargetNormalized from 0.0 to 1.0 from left to right and bottom to top.
u_clickvec3[0.5, 0.5, 0.0]Updated on mouse or touch press and release on canvas or cursorTargetxy is the normalized press position and z is 1.0 while pressed, otherwise 0.0.

Typical GLSL Declarations

uniform float u_time;
uniform int u_frame;
uniform vec2 u_resolution;
uniform vec2 u_cursor;
uniform vec3 u_click;

Note about u_resolution

If you use the helpers plugin, it injects the u_resolution declaration for you. Do not declare u_resolution manually in that case.

Previous
ShaderPad