Julia set
glint · Examples · Tutorials · Gallery
z → z² + c, with c slowly circling: the Julia set shifts from dust to dendrites to spirals. Smooth colouring from how fast each point escapes.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
One pass, in GLSL.
fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
in vec2 v_texcoord;
out vec4 fragColor;
float hash(float n) { return fract(sin(n * 127.1) * 43758.5453); }
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
vec2 hash2(float n) { return fract(sin(vec2(n * 127.1, n * 269.5)) * 43758.5453); }
mat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, s, -s, c); }
vec3 pal(float t) { return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))); }
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
vec2 z = uv * 2.6;
// c walks along the edge of the Mandelbrot set's main cardioid, where the Julia sets are most intricate.
float a = time * 0.1;
vec2 c = 0.5 * vec2(cos(a), sin(a)) - 0.25 * vec2(cos(2.0 * a), sin(2.0 * a));
c *= 1.0 + 0.03 * sin(time * 0.37);
float n = 0.0;
const float MAX = 200.0;
for (float i = 0.0; i < MAX; i++) {
z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
if (dot(z, z) > 256.0) break;
n++;
}
// Smooth iteration count: no bands between whole numbers.
float sn = n - log2(log2(dot(z, z))) + 4.0;
vec3 col = n >= MAX ? vec3(0.02, 0.0, 0.05) : pal(sn * 0.035 + time * 0.02) * (0.55 + 0.45 * sin(sn * 0.35));
fragColor = vec4(col, 1.0);
}More More GLSL examples
Rain on the window · 2D distance field playground · Gyroid cave · Mandelbrot zoom · Lava lamp · Circuit board · Snowfall