Shader Learn

11 GPU quirks

Macros, constants, loops and functions

Macros are replaced before compiling; functions and loops organize the math.

212

Runs once per pixelDrag numbers, or edit the code

JS sidegl.uniform2f(uResolution, …, …)

#define / #if replace text before compiling; const is a value that cannot change; in WebGL 1 a loop count must be a constant.

Try it

  • Change the petal count: every change recompiles
  • In the code, change TAU to 3.14 and see how the petals spread