Learn
Shader art for beginners
Most shader art is built from four ideas: noise, fractal Brownian motion, domain warping and distance fields. Here's each one, with the code jevai.art uses.
A fragment shader is a small function that runs once for every pixel on screen, in parallel, and returns that pixel's color. It knows the pixel's position and a few numbers you pass in, like the time, and nothing else. There's no "draw a circle" command. Everything you see has to be described as math on coordinates. That constraint is exactly what makes shader art interesting.
1. Noise: randomness that's smooth
Pure random numbers per pixel look like TV static. Art needs randomness that varies smoothly, so that nearby points get similar values. The simplest version is value noise: put a random number at each corner of a grid, and blend between them.
float noise(vec2 p) {
vec2 i = floor(p), f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f); // smooth the blend
return mix(mix(hash(i), hash(i + vec2(1, 0)), u.x),
mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), u.x), u.y);
}
Ken Perlin's gradient noise, developed in the early 1980s for computer-generated film effects, is the famous ancestor of this idea and is still everywhere.
2. Fractal Brownian motion: detail at every scale
One layer of noise looks like soft blobs. Nature has detail at every scale: coastlines, clouds and marble all have large shapes made of smaller shapes. Fractal Brownian motion (fbm) adds several layers of noise, each at twice the frequency and half the strength of the last.
float fbm(vec2 p) {
float v = 0.0, a = 0.5;
for (int i = 0; i < 5; i++) {
v += a * noise(p);
p = ROT * p * 2.02 + 3.1; // rotate and shift so layers don't align
a *= 0.5;
}
return v;
}
3. Domain warping: noise that flows
Here's the trick behind most "liquid" shader art, popularized by Inigo Quilez: instead of sampling noise at a point, sample it at a point that has itself been moved by noise. Do it twice and you get marble, smoke and ink in water.
vec2 q = vec2(fbm(p + t), fbm(p + vec2(5.2, 1.3) - t));
vec2 r = vec2(fbm(p + 3.0 * q + vec2(1.7, 9.2)), fbm(p + 3.0 * q + vec2(8.3, 2.8)));
float f = fbm(p + 3.0 * r);
In jevai.art, the warp strength comes from Jev's energy score, and dragging on the canvas pushes the warp around, which is why calm words give slow marble and restless ones give turbulence.
4. Distance fields: shapes as math
To draw a shape, a shader asks how far each pixel is from the shape's edge: negative inside, positive outside. That's a signed distance field. A circle is one line:
float orb = length(uv) - R;
Distance fields have a wonderful property: you can blend them. Mix the distance to a circle with the distance to a star, and the edge becomes a shape in between. jevai.art's outlines are six distance fields (orb, droplet, shard, bloom, cloud and ring) mixed by Jev's probabilities, which is why a hesitant reading produces shapes no single option would.
Bonus: growing things in polar coordinates
The fur, sparks and coral around the avatars use one more idea: measure each pixel's angle around the center and its distance above the outline, then split the angle into cells. Each cell grows one strand, spark or branch. The coral is a tiny fractal: draw a segment, fold space in half, rotate, shrink, and repeat six times. You get a branching tree from a loop of five lines.
Where to go next
Write a shader that shows noise(uv * 8.0) as grey, then swap in fbm, then warp it. Each step takes a minute and changes everything. Or skip the code and tell Jev something: every avatar on this site is these four ideas, tuned by how you feel.