No description
Find a file
Luis Alberto Flores Baca b663237a1d Add test github action
2023-07-24 15:45:16 -06:00
.github/workflows Add test github action 2023-07-24 15:45:16 -06:00
src * Extracted constants from vSeed ops 2021-12-19 23:08:33 -06:00
tests * Extracted constants from vSeed ops 2021-12-19 23:08:33 -06:00
.gitignore Added an initial implementation, a test suite and a small README file explaining the project 2021-12-18 00:34:55 -06:00
LICENSE Initial commit 2021-12-17 23:47:21 -06:00
opensimplexnoise.nimble * Improved code architecture in the module to be extended easy 2021-12-19 22:45:42 -06:00
README.md * Extracted constants from vSeed ops 2021-12-19 23:08:33 -06:00

Open Simplex Noise

This is a port of the open simplex noise algorithm based on KdotJPG C# Open Simplex Noise.

This implementation ports the C# implementation by KdotJPG without changing the sintax to be more nim-like, this can change in future releases to improve usage experience.

Instalation

nimble install opensimplexnoise

Usage

import opensimplexnoise

#[
    You can also provide a (seed : int64) parameter. Example:
    var noise = newOpenSimplex(141228)
]#
var noise: OpenSimplex = newOpenSimplex()

echo noise.evaluate(0.01, 0.02) # 2D noise
echo noise.evaluate(0.01, 0.02, 0.03) # 3D noise
echo noise.evaluate3XYBeforeZ(0.01, 0.02, 0.03) # 3D noise
echo noise.evaluate3XZBeforeY(0.01, 0.02, 0.03) # 3D noise
echo noise.evaluate(0.01, 0.02, 0.03, 0.04) # 4D noise

Known Issues

This is a very early version of the implementation that could have bugs, however, this was tested using a large dataset generated using the KdotJPG C# implementation (see tests/suite folder) and it passed all the tests, that means that it produces the same output as the original version.

The only possible bug that needs to be solved is that for the newOpenSimplex function there are some integer overflows needed. This is a bad practice for most programs so nim adds some checks to the generated program that avoids them throwing exceptions at running time. I tryed to disable that checks enclosing the unsecure code between {.push overflowChecks: off.} and {.pop.} but for some reason I need to also provide the -d:danger parameter in the CLI i.e. to test I run:

nimble -d:danger test

More Information

For more information about the way all the OpenSimplexNoise methods work visit the KdotJPG resources:

Thanks Kurt Spencer for developing this awesome algorithm.