Shader Learn

02 Drawing shapes with math

step: a switch

Below the threshold you get 0, otherwise 1.

01
ExerciseTune values0%

Put the boundary at 30%

Runs once per pixelDrag numbers, or edit the code

step(edge, x) returns 0 when x < edge, otherwise 1. It is the cheapest “if” in a shader.

Try it

  • Set the threshold to 0.3
  • Change vUv.x to vUv.y: the boundary turns horizontal