Shader Learn

01 Fragments and data

vec2: two numbers in one value

Two floats that together mean X and Y. Drag the numbers in the code and the dot moves.

01
01
Explanation

Drag the underlined numbers left and right

vec2 point = vec2(, );// these two components place the dot on the left// point.x -> left/right// point.y -> up/down
vec2Two floats
RangeBottom left (0, 0) → top right (1, 1)
JS sidegl.uniform2f(uResolution, …, …)

A vec2 packs two floats together, often a coordinate. Bottom left is (0,0), top right (1,1).

Try it

  • Move the dot to the top right corner
  • Put the dot dead centre: what should the two numbers be?