A shader is a small program that runs on your graphics card and decides the color of pixels. GLSL is one of the languages shaders are written in. It is used in games, in creative coding tools and on websites, and it is behind many of the effects you see in visual art today.
You do not need to be a programmer to understand the idea.
The one big idea
A normal program does things one after another. A shader works differently:
The same small piece of code runs for every pixel at the same time.
Each pixel asks one question: "Given where I am, and what time it is, what color should I be?" The shader answers it. Because the graphics card has thousands of tiny cores, it can answer for millions of pixels many times per second.
A tiny example
uniform vec2 u_resolution;
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}
In plain words:
u_resolutionis the canvas size, sent in from outside.uvis the pixel's position, from 0 to 1 across the screen.- The red channel grows from left to right, green from bottom to top.
- The result is a smooth color gradient over the whole canvas.
Add time to the math and the gradient moves. Read a photo instead of a fixed color and you have an effect.
Two kinds of shaders
- Fragment shaders decide the color of each pixel. This is where almost all visual effects happen.
- Vertex shaders decide where the corners of shapes go. They matter most for 3D.
For 2D effects and art, you mostly write fragment shaders.
Uniforms: the knobs
A uniform is a value you send into the shader from outside, the same for every pixel. Time, the mouse position, the canvas size or a slider you made yourself are all uniforms. They are how a shader becomes something you can play with, instead of a fixed picture.
What people make with shaders
- Effects on photos and video: dots, glitches, color grades, warps.
- Generative art: patterns, noise landscapes and fractals made only from math.
- Music visualizers that react to bass and treble.
- Transitions and backgrounds for videos and live shows.
Where to start
The fastest way to learn is to change numbers in a working shader and watch what happens. That is how most shader artists started.
Code mode in Dasca is made for this:
- The shader compiles about a second after you stop typing, so you see every change live.
- Your own uniforms turn into sliders, which you can keyframe on a timeline.
- You can run your shader on your own image or video, or on nothing at all.
- Audio uniforms like
u_audioBasslet your shader react to music. - Example shaders like Pulse Halftone and Spectrum Halo give you working code to take apart.
When the result looks right, record it as a video. See the Code docs for every uniform and option. Prefer effects without code? The same dot look as Pulse Halftone is one click away with the Halftone effect.
