1 unstable release
new 0.0.0 | Jan 13, 2025 |
---|
#24 in #simplex-noise
24 downloads per month
700KB
199 lines
noise
2D Noise generation utilities
Usage
This crate provides a simple API for creating Noise
objects which can be sampled within the unit square:
let mut rng = thread_rng();
let noise = Perlin::new(SHAPE, &mut rng);
let value = noise.sample([0.25, 0.75]);
Features
Perlin Noise
Simplex Noise
Worley Noise
Stacks
You can stack multiple weighted noise functions together into a single noise function using the Stack
struct:
let noise = Stack::new(vec![
(Box::new(Perlin::new((5, 5), &mut rng)), 1.0),
(Box::new(Perlin::new((7, 7), &mut rng)), 0.5),
(Box::new(Perlin::new((11, 11), &mut rng)), 0.25),
(Box::new(Perlin::new((23, 23), &mut rng)), 0.125),
(Box::new(Perlin::new((43, 43), &mut rng)), 0.0625),
]);
Stacked Perlin noise
Stacked Simplex noise
Tileable Noise
By default all noise types other than Simplex noise will repeatedly tile.
Examples
You can run the examples to generate images of the noise functions.
First, clone the repository and set the current directory to the root of the repository:
git clone https://github.com/FreddyWordingham/noise.git
cd noise
Make sure to create the ./output
directory for the images to be saved to:
mkdir ./output
Then, build the examples:
cargo build --release --examples
And run the example you want to generate an image. For example, to generate an image of stacked Simplex noise:
cargo run --release --example simplex_stack
Dependencies
~4.5MB
~85K SLoC