Shader Learn

02 Drawing shapes with math

Transforms: move the coordinates first

Transform the coordinates, then draw the same square.

-0.40.4
0.43
-3.143.14
ExerciseTune values0%

Make this square: shifted right, smaller, turned 45°

Runs once per pixelDrag numbers, or edit the code

JS sidegl.uniform2f(uResolution, …, …)

You transform the coordinates, not the shape: p − offset moves the shape toward offset; scaling the coordinates up makes the shape smaller.

Try it

  • Set scale to 2: did the square get smaller or bigger?
  • Rotate by 0.785 (45°): the square becomes a diamond