Fast Voronoi Diagrams and Distance Field Textures on the GPU With the Jump Flooding Algorithm

Created on 2023-02-09T17:56:32-06:00

Return to the Index

This card pertains to a resource available on the internet.

This card can also be read via Gemini.

Creates voronoi diagrams from a set of "seeds."

Seeds can be individual points or entire shapes. Voronoi cells and distance transforms will be centered around whatever symbols are fed in to the algorithm but single pixels are common.

Jump filling is an approximation; it will make small errors compared to brute force but is very quick for GPUs to compute.

Algorithm

Steps: If you have an NxN output texture then there are log2(N) steps in total.

Step size: the step size for each group is 2^(log2(N) - pass - 1) calculated at the start of each pass

K: the step size

Offset kernel:

(-K.0, -K.0), (0.0, -K.0), (K.0, -K.0),
(-K.0,  0.0), (0.0,  0.0), (K.0,  0.0),
(-K.0,  K.0), (0.0,  K.0), (K.0,  K.0)

The result is a texture map where each pixel has been replaced with coordinate pixels for the voronoi cell it belongs to.

This can be converted to a signed distance field by checking each pixel and replacing it with the pixel's distance to its seed coordinates.