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.0, 0.0]Updated on mouse or touch movement when cursorTarget is availableNormalized from 0.0 to 1.0 from left to right and bottom to top over the active cursorTarget.
u_clickvec3[0.0, 0.0, 0.0]Updated on mouse or touch press and release when cursorTarget is availablexy is the normalized press position and z is 1.0 while pressed, otherwise 0.0.

If no cursorTarget is available, u_cursor and u_click stay at their initial values.

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