Who dis for?
This text is aimed for developers who want to learn fragment shaders who come from a background of JavaScript, Processing, Processing.js, P5.js, etc. It's also not for anyone who likes really dry technical stuff. I'm writing this pretty informally since I basically don't have a lot of time on my hands.
What's NOT a fragment shader?
A fragment shader isn't just some thing that calculates lighting. It's also not a vertex shader or geometry shader. Those things are for doing other stuff.
A fragment shader is just some code that gets executed on the GPU on your computer instead of the CPU. You can imagine that shaders run pretty damn fast because gamers sure like their FPS. This need for performance has given manufacturers lots of $$ to pour into the effort of making GPUs fast. Thanks gamers!
So, why is it called a shader? Basically, as far as I know the name comes from ShaderTree which used to only be responsible for ligthing...but since then things have changed and we can use fragment shaders for much more interesting things.
At the end of the day, a fragment shader calculates a color for every pixel of a surface on a 3D primitive. That's basically all it does.
TL;DR
- This is for Processing folks who wanna learn fragment shaders
- Each pixel of a 'surface' has the same fragment shader run on it to determine its color
- Shaders are minblowingly fast