src/perlin

A Noise Generation Library with support for both Perlin noise and Simplex noise.

Simplex Noise

Take a look here:

Based on the implementation found here:

Perlin Noise

Take a look at the following resources:

Perlin noise generation 3D Simplex noise generation

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(): Noise {....raises: [], tags: [].}
Creates a new noise instance with a random seed
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
proc simplex(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 simplex(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