home/ atoms/ hydra-shaders-gpu

A whole Hydra chain compiles to one GPU shader that computes every pixel in parallel

When a Hydra chain executes, the entire chain — source plus every transform plus the output — compiles down to a single shader: one program that runs on the graphics card. A shader is parallel: the same program runs simultaneously for every pixel, each instance independently deciding ‘what color should this pixel be?’ The GPU has no notion of shapes or layers; it only sets a color per pixel. So rather than the CPU issuing many draw calls, one compiled shader computes all pixels at once. This is why chains stay cheap however long they get — adding a stage extends the shader program rather than adding a render pass — and why per-pixel operations like modulate and feedback run in real time. Because Hydra works directly at the shader level, matching the GPU’s pixel-parallel execution model, it stays fast enough for real-time performance in a browser. Contrast with CPU-side, imperative draw commands (e.g. Processing’s ellipse(x,y,w,h)), which are more sequential.

Examples

osc().rotate().modulate(osc()).out() — several chained methods, but one GLSL shader runs in parallel over every pixel each frame, holding interactive frame rates. Compare Processing’s ellipse(x, y, w, h), an imperative CPU-side draw call.

Assessment

Explain what a shader is and why a long Hydra chain compiles to one shader rather than many draw calls. Identify the GPU property that makes per-pixel operations (like modulate and feedback) cheap, and use the GPU-vs-CPU distinction to explain why Hydra runs complex chains at interactive frame rates in a browser.

“it's all running directly on the graphics card so each chain of function surrenders to a shader which is a program that runs on the graphics card”
corpus · live-coding-visuals-with-hydra-olivia-jack-no-bounds-eulerro · chunk 2
“at the end of the day you know like the computer doesn't actually know what what a shape is a square or any of that but you're just telling it put this color in this pixel”
corpus · olivia-jack-hydra-live-coding-visuals-in-the-browser-talk · chunk 1