Expand description
Fast and lightweight noise algorithm implementations.
Check out the live demo!
The implementation of these noise functions are from FastNoiseLite (github/crate).
§Examples
use noise_functions::{ Perlin, CellDistance, OpenSimplex2s, Sample2, Sample3, NoiseFn };
let point = [1.0, 2.0];
// perlin noise
let value = Perlin.sample2(point);
// seeded perlin noise
let value = Perlin.seed(42).sample2(point);
// fractal perlin noise
let value = Perlin.fbm(3, 0.5, 3.0).sample2(point);
// seeded fractal perlin noise
let value = Perlin.fbm(3, 0.5, 3.0).seed(42).sample2(point);
// perlin noise with adjusted frequency
let value = Perlin.frequency(3.0).sample2(point);
// cell distance (voronoi/worley) noise
let value = CellDistance.sample2(point);
// cell distance (voronoi/worley) noise with jitter multiplier
let value = CellDistance.jitter(0.5).sample2(point);
// domain warped OpenSimplex2s noise
let warped_noise = |point: [f32; 2]| {
let warp_x = OpenSimplex2s.seed(1).sample2(point);
let warp_y = OpenSimplex2s.seed(2).sample2(point);
let warped = [point[0] + warp_x, point[1] + warp_y];
OpenSimplex2s.sample2(warped)
};
let value = warped_noise(point);
let point = [1.0, 2.0, 3.0];
// 3d OpenSimplex2s noise
let value = OpenSimplex2s.sample3(point);
// 3d OpenSimplex2s noise with improved isotropy in the xy plane
let value = OpenSimplex2s.improve_xy().sample3(point);
§Feature flags
std
(enabled by default) — Uses floating point functions from the standard library.libm
— Useslibm
for floating point functions. Required forno_std
.nightly-simd
— Adds support for sampling with simd types.
Modules§
- Cellular noise functions and combinators.
- Fractal noise combinators.
- OpenSimplex2 noise functions and combinators.
Structs§
- 2/3 dimensional noise of the distance to the closest cell
- 2/3 dimensional noise of the squared distance to the closest cell
- 2/3 dimensional noise of the value of the closest cell
- Wraps a noise and modifies its frequency.
- Wraps a function to make it implement
Sample
. - 2/3 dimensional OpenSimplex2 noise. Fast variant.
- 2/3 dimensional OpenSimplex2s noise. Smooth variant.
- 2/3 dimensional Perlin noise
- Wraps a noise with a seed.
- 2/3 dimensional Value noise
- 2/3 dimensional Cubic Value noise
Traits§
- Trait for sampling noises.
- Helper trait that provides
sample2
as a shorthand forSample<2, [f32; 2]>::sample
. - Helper trait that provides
sample3
as a shorthand forSample<3, [f32; 3]>::sample
. - Sample2a
nightly-simd
Helper trait that providessample2a
as a shorthand forSample<2, f32x2>::sample
. - Sample3a
nightly-simd
Helper trait that providessample3a
as a shorthand forSample<3, f32x4>::sample
.