#noise #simplex #perlin #procedural #terrain

no-std fastnoise-lite

FastNoiseLite is an extremely portable open source noise generation library with a large selection of noise algorithms

2 stable releases

1.1.0 Oct 15, 2023
1.0.1 Oct 6, 2023

#145 in Images

Download history 9/week @ 2023-10-29 1/week @ 2023-11-05 10/week @ 2023-11-12 6/week @ 2023-11-19 13/week @ 2023-11-26 4/week @ 2023-12-03 20/week @ 2023-12-10 144/week @ 2023-12-17 57/week @ 2023-12-24 125/week @ 2023-12-31 162/week @ 2024-01-07 110/week @ 2024-01-14 43/week @ 2024-01-21 63/week @ 2024-01-28 101/week @ 2024-02-04 86/week @ 2024-02-11

296 downloads per month

MIT license

135KB
2.5K SLoC

crates.iodocs.rsGitHub

FastNoise Lite

FastNoise Lite is an extremely portable open source noise generation library with a large selection of noise algorithms. This library focuses on high performance while avoiding platform/language specific features, allowing for easy ports to as many possible languages.

Features

  • 2D & 3D
  • OpenSimplex2 Noise
  • OpenSimplex2S Noise
  • Cellular (Voronoi) Noise
  • Perlin Noise
  • Value Noise
  • Value Cubic Noise
  • OpenSimplex2-based Domain Warp
  • Basic Grid Gradient Domain Warp
  • Multiple fractal options for all of the above
  • Supports floats and/or doubles
    • Switch from f32 to f64 position inputs with the "f64" feature flag in your Cargo.toml

Getting Started

Below is an example for creating a 128x128 array of OpenSimplex2 noise.

Additional documentation is available at docs.rs and the project's Getting Started and Documentation pages from its GitHub wiki.

use fastnoise_lite::*;

// Create and configure FastNoise object
let mut noise = FastNoiseLite::new();
noise.SetNoiseType(NoiseType::OpenSimplex2);

const WIDTH: usize = 128;
const HEIGHT: usize = 128;
let mut noise_data = [[0.; HEIGHT]; WIDTH];

// Gather noise data
for x in 0..WIDTH {
    for y in 0..HEIGHT {
        // Assuming `noise.get_noise_2d(x, y)` returns a float, and takes f32 parameters.
        // Adapt accordingly if the function signature is different.
        noise_data[x][y] = noise.get_noise_2d(x as f32, y as f32);
    }
}

// Do something with this data...

Dependencies

~100KB