arlyon / bluenoise-rs

Ergonomic blue noise (poisson disk sampling) for the masses.
https://crates.io/crates/bluenoise
Apache License 2.0
7 stars 4 forks source link

Add `WrappingBlueNoise` #6

Closed benfrankel closed 3 years ago

benfrankel commented 3 years ago

WrappingBlueNoise is like BlueNoise, but it considers points on opposite edges of the box to be near each other. This allows the generated blue noise to tile with itself without forming clusters of points at the edges / corners where tiles meet.

I tried to avoid performance regressions for the non-wrapping blue noise case, keep the API simple, and avoid code duplication in that order. There's probably a better way to implement this, though.

benfrankel commented 3 years ago

Right now WrappingBlueNoise seems about 2x slower than BlueNoise on my machine, which makes sense. I think it could be optimized by adding a 2-wide border of cells around the grid, then duplicating points that are near the border in insert_point so that the distance calculations in is_valid can be much faster.

arlyon commented 3 years ago

Right now WrappingBlueNoise seems about 2x slower than BlueNoise on my machine, which makes sense. I think it could be optimized by adding a 2-wide border of cells around the grid, then duplicating points that are near the border in insert_point so that the distance calculations in is_valid can be much faster.

I think for now the hit is okay. If you would like to create an issue just to keep track we can decide if it needs to be changed down the line.

benfrankel commented 3 years ago

Updated the PR, and created an issue: #7.

arlyon commented 3 years ago

Good stuff, thanks for the patch!