10 releases (5 breaking)

new 0.5.0 Jan 16, 2025
0.4.0 Jan 16, 2025
0.3.0 Nov 29, 2024
0.2.1 May 4, 2024
0.0.0 Apr 26, 2024

#395 in Algorithms

Download history 14/week @ 2024-09-27 152/week @ 2024-11-29 37/week @ 2024-12-06 12/week @ 2024-12-13 1/week @ 2024-12-20 2/week @ 2025-01-03 118/week @ 2025-01-10

128 downloads per month
Used in noise-functions-config

MIT/Apache

220KB
5K SLoC

Noise Functions

Crates.io Documentation Rust License

Fast and lightweight noise functions.

Check out the live demo!

Example Images

Click on the images to view the code that created them.

Basic

Fractal

Domain warped

Tileable

Motivation

Noise libraries like noise or libnoise create a permutation table at runtime for each instance of Perlin and the like. This library uses static permutation tables / hashing instead. As such, there is no need to store and reuse noise structs for the sake of efficiency. For example:

fn my_noise(point: Vec2) -> f32 {
    Perlin.fbm(3, 0.5, 2.0).seed(42).frequency(3.0).sample2(point)
}

In this example, the whole Perlin.fbm(3, 0.5, 2.0).seed(42).frequency(3.0) expression is evaluated at compile time.

[!NOTE] This library uses f32 instead of f64.

Why not fastnoise-lite?

fastnoise-lite provides its noise generation via a big struct that you are to mutate to get the noise you want. If you already know what noise you want or you want to compose multiple noises in a custom way then this design is less efficient and less convenient. There is the noise-functions-config crate that provides a similar configurable struct (the demo is powered by it). It opts to return a trait object like Box<dyn Sample<2>> instead of branching on each sample call.

[!NOTE] The implementation of the current noise functions are from FastNoiseLite. The simd versions were created by me.

Dependencies

~125KB