Super fast SIMD noise library for Rust. PRs welcome!
Available on crates.io.
See above crates.io link for Docs.
Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz Single Threaded using Criterion.rs
| SIMD Set | Time | |----------|------| | scalar| 21.289 us| | sse2 | 8.203 us| | sse41 | 6.598 us| | avx2 | 3.174 us|
| SIMD Set | Time | |----------|------| | scalar| 5.351 ms| | sse2 | 1.766 ms| | sse41 | 1.562 ms| | avx2 | 0.880 ms|
| SIMD Set | Time | |----------|------| | scalar| 3.173 ms| | sse2 | 1.631 ms| | sse41 | 1.440 ms| | avx2 | 0.882 ms|
| SIMD Set | Time | |----------|------| | scalar| 534 us| | sse2 | 345 us| | sse41 | 305 us| | avx2 | 144 us|
| SIMD Set | Time | |----------|------| | scalar| 37.220 ms| | sse2 | 30.780 ms| | sse41 | 20.492 ms| | avx2 | 8.697 ms|
| SIMD Set | Time | |----------|------| | scalar| 3.964 ms| | sse2 | 3.660 ms| | sse41 | 2.251 ms| | avx2 | 1.182 ms|
The library will, at runtime, pick the fastest available options between SSE2, SSE41, and AVX2
```rust use simdnoise::*;
// Set up noise type and parameters let noise_type = simdnoise::NoiseType::Fbm { freq: 0.04, lacunarity: 0.5, gain: 2.0, octaves: 3, };
// Get a block of 2d 800x600 noise, with no scaling of resulting values // min and max values are returned so you can apply your own scaling let (anf32vec,min,max) = simdnoise::get2dnoise(0.0, 800, 0.0, 600, noise_type);
// Get a block of 200x200x200 3d noise let (anf32vec,min,max) = simdnoise::get3dnoise(0.0, 200, 0.0, 200,0.0, 200, noise_type);
// Get a block of noise scaled between -1 and 1 let anf32vec = simdnoise::get2dscalednoise(0.0, 800, 0.0, 600, noisetype,-1.0,1.0); ```
Sometimes you need something other than a block, like the points on the surface of a sphere. Sometimes you may want to use SSE41 even with AVX2 is available
```rust
// get a block of 100x100 sse41 noise, skip runtime detection let (noise,min,max) = simdnoise::sse41::get2dnoise(0.0,100,0.0,100,noise_type);
// send your own SIMD x,y values to the noise functions directly unsafe { // sse2 simplex noise let x = mmset1ps(5.0); let y = _mmset1ps(10.0); let f : _m128 = simdnoise::sse2::simplex_2d(x,y);
// avx2 turbulence let x = mm256set1ps(5.0); let y = _mm256set1ps(10.0); let freq = _mm256set1ps(1.0); let lacunarity = mm256set1ps(0.5); let gain = _mm256set1ps(2.0); let octaves = 3; let fturbulence : _m256 = simdnoise::avx2::turbulence2d(x,y,freq,lacunarity,gain,octaves);
} ```