Fast Noise - A Noise Library For D

jordan4ibanez jordan4ibanez002 at gmail.com
Sat Aug 20 01:03:15 UTC 2022


I noticed that D was missing a flexible functional multi use 
noise library for game development. I fixed this by translating 
Auburn's Fast Noise - Lite into D as it's a header only 
implementation of multiple noise algorithms. These include:

- 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

The default is double.

You can see/get it here: 
https://code.dlang.org/packages/fast_noise

Here is an example on how to use it:

```d
import std.stdio;
import std.random;
import fast_noise;

void main() {
     // This is an example on how to use the library
     FNLState noise = fnlCreateState();
     noise.seed = unpredictableSeed();
     noise.noise_type = FNLNoiseType.FNL_NOISE_PERLIN;
     writeln("Begin perlin noise:");
     for (double i = 0; i < 100; i++) {
         double test = fnlGetNoise3D(&noise, 0,i,0);
         writeln("noise: ", test);
     }

     // You can also initialize it with a seed
     FNLState moreNoise = fnlCreateState(unpredictableSeed());
     moreNoise.noise_type = FNLNoiseType.FNL_NOISE_OPENSIMPLEX2;
     writeln("Begin OpenSimplex2 noise:");
     for (double i = 0; i < 100; i++) {
         double test = fnlGetNoise3D(&moreNoise, 0,i,0);
         writeln("noise: ", test);
     }

}```


Hopefully this small library gets you going on your noise 
generated implementation for your video game. Thanks for reading.


More information about the Digitalmars-d mailing list