Shader Learn

A Appendix

Playground: paste any shader

Paste a fragment shader written by an agent, found online or written by you. WebGL 1 void main works, and so does Shadertoy’s mainImage (without iChannel textures); iTime, iResolution, iMouse and u_time, u_resolution, u_mouse are connected for you.

Actual GPU sourceDrag numbers, or edit the code

JS sidegl.uniform2f(uResolution, …, …) gl.uniform1f(uTime, 0.00)

To read unfamiliar code, first sort it into the five layers (space, shape, edge, paint, time), then open the pixel debugger and show each variable on the canvas. Before changing a number, predict what will happen: wherever you guess wrong is what you haven’t understood yet.

Try it

  • Select all the code and paste a shader from Shadertoy (the mainImage kind)
  • Ask an agent for a shader, and ask it to comment each line by layer: space → shape → edge → paint → time; paste it in and read along
  • Open the pixel debugger and show d on the canvas: the distance map from the shape layer
  • Before changing a number, say what the picture will do, then change it to check