www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Fast Noise - A Noise Library For D

reply jordan4ibanez <jordan4ibanez002 gmail.com> writes:
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.
Aug 19 2022
next sibling parent Guillaume Piolat <first.last example.com> writes:
On Saturday, 20 August 2022 at 01:03:15 UTC, jordan4ibanez wrote:
 Hopefully this small library gets you going on your noise 
 generated implementation for your video game. Thanks for 
 reading.
Pretty cool! This will be super useful.
Aug 22 2022
prev sibling parent reply Johan <j j.nl> writes:
On Saturday, 20 August 2022 at 01:03:15 UTC, jordan4ibanez wrote:
 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.
I see that [Auburn's Fast Noise Lite repository](https://github.com/Auburn/FastNoiseLite) contains implementations for several languages. Consider uploading your D port to that repo, to give it more visibility and discoverability (or add a link in the readme of that repo to your repo). cheers, Johan
Aug 24 2022
parent jordan4ibanez <jordan4ibanez002 gmail.com> writes:
On Wednesday, 24 August 2022 at 08:08:21 UTC, Johan wrote:
 On Saturday, 20 August 2022 at 01:03:15 UTC, jordan4ibanez 
 wrote:
 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.
I see that [Auburn's Fast Noise Lite repository](https://github.com/Auburn/FastNoiseLite) contains implementations for several languages. Consider uploading your D port to that repo, to give it more visibility and discoverability (or add a link in the readme of that repo to your repo). cheers, Johan
That is a good idea. Also about the link, if you looked at the dub package/github repo I did link to the original file in the repo that this was translated from :P
Aug 25 2022