View Source Perlin (perlin v0.1.0)
An implementation of Ken Perlin's improved Perlin noise algorithm in Elixir.
This module provides functions to generate 3D Perlin noise, which can be used for procedural generation of textures, terrains, and other natural-looking patterns. It includes both single-octave noise generation and multi-octave noise for more complex and detailed results.
The implementation is based on Ken Perlin's improved noise function from 2002, which addressed some of the visual artifacts present in his original 1985 algorithm.
Key features:
- 3D noise generation
- Optional repetition of noise pattern
- Multi-octave noise for more natural-looking results
- Configurable persistence for octave-based noise
Summary
Functions
Generates 3D Perlin noise for given coordinates.
Generates Perlin noise with multiple octaves.
Functions
Generates 3D Perlin noise for given coordinates.
Parameters
x
- X coordinate in the noise spacey
- Y coordinate in the noise spacez
- Z coordinate in the noise spacerepeat
- Optional. The interval at which the noise pattern repeats. Default is -1 (no repetition).
Returns
A float value between 0 and 1 representing the noise at the given coordinates.
Example
iex> Perlin.noise(3.14, 42.0, 7.0)
0.5684599793920001
iex> Perlin.noise(3.14, 42.0, 7.0, 5)
0.44100014719999997
Generates Perlin noise with multiple octaves.
Parameters
x
- X coordinate in the noise spacey
- Y coordinate in the noise spacez
- Z coordinate in the noise spaceoctaves
- Number of octaves to sumpersistence
- Amplitude multiplier for each octave
Returns
A float value between 0 and 1 representing the noise at the given coordinates.
Example
iex> Perlin.octave(3.14, 42.0, 7.0, 4, 0.5)
0.5530014285141335