A Noise Generation Library with support for both Perlin noise and Simplex noise.
Simplex Noise
Take a look here:
- http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
- http://stackoverflow.com/questions/18279456/any-simplex-noise-tutorials-or-resources
Based on the implementation found here:
Perlin Noise
Take a look at the following resources:
- http://mrl.nyu.edu/~perlin/noise/
- http://flafla2.github.io/2014/08/09/perlinnoise.html
- http://riven8192.blogspot.com/2010/08/calculate-perlinnoise-twice-as-fast.html
Types
Noise = object perm: array[0 .. 511, int] octaves: int persistence: float
-
A noise instance
- perm is a set of random numbers used to generate the results
- octaves allows you to combine multiple layers of noise into a single result
- persistence is how much impact each successive octave has on the result
NoiseType {.pure.} = enum perlin, simplex
- The types of noise available
Procs
proc get(self: Noise; typ: NoiseType; x, y, z: int | float): float
-
Returns the noise at the given offset. Returns a value between 0 and 1
Note: This method tweaks the input values by just a bit to make sure there are decimal points. If you don't want that, use the 'purePerlin' method instead
proc get(self: Noise; typ: NoiseType; x, y: int | float): float
-
Returns the noise at the given offset. Returns a value between 0 and 1
Note: This method tweaks the input values by just a bit to make sure there are decimal points. If you don't want that, use the 'purePerlin' method instead
proc newNoise(octaves: int; persistence: float): Noise {....raises: [], tags: [].}
-
Creates a new noise instance with a random seed
- octaves allows you to combine multiple layers of noise into a single result
- persistence is how much impact each successive octave has on the result
proc newNoise(seed: uint32; octaves: int = 1; persistence: float = 0.5): Noise {. ...raises: [], tags: [].}
-
Creates a new noise instance with the given seed
- octaves allows you to combine multiple layers of noise into a single result
- persistence is how much impact each successive octave has on the result
proc perlin(self: Noise; x, y, z: int | float): float
-
Returns the noise at the given offset. Returns a value between 0 and 1
Note: This method tweaks the input values by just a bit to make sure there are decimal points. If you don't want that, use the 'purePerlin' method instead
proc perlin(self: Noise; x, y: int | float): float
-
Returns the noise at the given offset. Returns a value between 0 and 1
Note: This method tweaks the input values by just a bit to make sure there are decimal points. If you don't want that, use the 'purePerlin' method instead
proc pureGet(self: Noise; typ: NoiseType; x, y, z: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc pureGet(self: Noise; typ: NoiseType; x, y: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc purePerlin(self: Noise; x, y, z: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc purePerlin(self: Noise; x, y: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc pureSimplex(self: Noise; x, y, z: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc pureSimplex(self: Noise; x, y: int | float): float
- Returns the noise at the given offset without modifying the input. Returns a value between 0 and 1
proc randomSeed(): uint32 {.inline, ...raises: [], tags: [].}
- Returns a random seed that can be fed into a constructor