11 GPU quirks
No printf: debug with colour
Output an intermediate value as colour. Careful: negatives, values above 1 and NaN all “lie” to you.
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniform2f(uResolution, …, …)Shaders have no printf: output the value as colour. Negatives and values above 1 get clamped, and what NaN looks like depends on the device.
Try it
- Look at d with “Raw output”: why is the inside of the circle all black?
- Switch to “Out-of-range marks”: blue is negative
- Pick log(d) and see where NaN appears