GLSL shader example

Glowing Voronoi Cracks

Use the difference between the nearest two cell distances as an edge approximation; only near-equality boundaries emit light.

Live example

Edit the code and the preview updates as you type.

What to observe

Glowing Voronoi Cracks.

Mechanism

Use the difference between the nearest two cell distances as an edge approximation; only near-equality boundaries emit light.

The controlling code

float d=cellEdge(p*4.);float glow=exp(-d*(12.+40.*u_parameter));c=vec3(.08+.07*noise(p*20.))+vec3(1.,.28,.05)*glow;

Experiment

Set the parameter to 0 and then 1 to change exp(-d*(12.+40.*u_parameter)) from a broad to a narrow glow. The cell boundaries stay in the same positions because their input remains p*4..

Debugging and cost

cellEdge checks a 3×3 neighborhood to approximate the gap between the two nearest seed distances. Change cellEdge(p*4.) to cellEdge(p*2.) to double the crack-cell size while keeping the same nine-neighbor search.

Built-in functions used

Learn it step by step