Hard PatternsAnimated

Cellular Voronoi

Moving cell centers; each pixel shows its distance to the nearest one.

The target picture for the shader challenge "Cellular Voronoi"
Recreate this picture. You pass at a 99% match, then try to write it in fewer characters than the par.

How this challenge works

You write a fragment shader that draws the picture above, live in your browser. A match bar shows how close you are, and the score combines accuracy, code size (the par is 604 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.

The numbers you need

Grid
g = uv * float2(6.0, 4.5); id = floor(g); f = frac(g)
Search
the 3 × 3 neighbouring cells (int loops from -1 to 1)
Point in a cell
o = hash2(id + b); o = 0.5 + 0.5 * sin(time + 6.28318 * o) (b = the neighbour offset)
Distance
d = min(d, length(b + o - f)) starting at 8.0
Color
lerp(float3(0.9,0.6,0.2), float3(0.1,0.15,0.35), smoothstep(0.0, 0.8, d)) + (1.0 - smoothstep(0.0, 0.06, d))

Helper functions provided

The toolbox has: hash2(). Add them above your frag function with one click.

Solve it in your language

Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.

Start coding