Voronoi noise creates sharp, cellular patterns. Unlike Perlin or Simplex noise which creates smooth gradients, Voronoi noise produces sharp, crystalline patterns. It’s based on Voronoi diagrams, where each point belongs to the closest seed.
How?
Voronoi diagrams can be generated through several algorithms:
- Brute Force: For each pixel, calculate distance to all seeds and assign to closest
- Fortune’s Algorithm: Sweep line algorithm for efficient computation
- Jump Flooding Algorithm: GPU-friendly method for real-time generation
Brute Force Algorithm Logic
The logic works by checking every pixel against every seed, which is simple but slow for large grids or many seeds.
It is like a nested loop:
- For each
currentPixelin the grid:- Initialize
minimumDistanceto a very large number (like 999999), andclosestSeedto null. - For each
seedPointin the list of seeds:- Calculate
distanceToSeed= - If
distanceToSeed<minimumDistance, setminimumDistance=distanceToSeedandclosestSeed=seedPoint
- Calculate
- Assign
currentPixeltoclosestSeed’s cell.
- Initialize
This “counts” by comparing distances to find the closest seed for each point. Boundaries form where distances to two seeds are equal.