Shader Learn

03 Time, interaction and repetition

uniform: passing time in

JavaScript passes the seconds in every frame. Pause, then drag the time, and the picture jumps.

-44
112
010

Runs once per pixelDrag numbers, or edit the code

JS sidegl.uniform2f(uResolution, …, …) gl.uniform1f(uTime, 0.00) // every frame (requestAnimationFrame) const seconds = elapsed + jump gl.uniform1f(uTimeLocation, seconds) gl.drawElements(...)

A shader cannot keep time or remember the last frame. JS passes a new uTime each frame; the same time always gives the same picture.

Try it

  • Pause, then change “Jump to time”: the picture jumps with it
  • Make the speed negative: the ripples go backwards