I figured I'd jot down a few notes that have started to help me wrap my head around how GLSL works. To be honest, I've had to reference these thoughts quite a bit because I don't work with the language consistently. The best technical reference, IMO, is still from the Book of Shaders but I hope someone finds my perspective helpful.

*Note: As part of my GLSL in TouchDesigner quick reference, this post will continue to evolve as I dive into this strange, new world.

UV Space

Everything happens within an image tile that goes from 0...1 in both X and Y axis (and though I haven't delved into 3D GLSL yet, I'm assuming Z as well). By normalizing this coordinate space, it doesn't matter what your image resolution is. The bottom left is always [0, 0] — the top left [0, 1] — the bottom right [1, 0] — and finally the top right is [1, 1].

*Normalizing means "remapping" the values to fit within a 0...1 space.

Blind Execution

Think of each pixel in the UV space as a tiny computer awaiting your instruction. For every frame, all of those tiny computers execute your command in parallel. Because each one acts independently, it means it can process your requests FAST. The downside is that it also means nobody knows what their neighbor is doing because everything is happening at once. So, you can't modify or pass along data/knowledge between each other.


In order to get things moving, we have to introduce the element of time. Do yourself a favor and go over "shaping functions" once, twice, thrice more — it's exactly the same for time instead of pixels. Except you don't get a visual timeline with keyframes, so I try to visualize the timing curve in my mind based on that idea of 'shaping'. It also helps to think of your timeline existing in that same normalized space. It's tricky.

Especially when realizing that each little computer friend in our adorable GPU army only ever returns a color. So the pixels themselves are never really "moving" — you're just creating an illusion of motion by telling each one what new, updated position of your texture to sample based on the change in real-time. Woah. Understand that there is no spoon.