Simplex:
Filter:
SimplexNoise-SC/Classes (extension) | Random

Simplex
ExtensionExtension

Simplex (spatial) noise functions

Description

This class is just a group of functions to generate Simplex Noise (https://en.wikipedia.org/wiki/Simplex_noise) in 2D, 3D and 4D space. In a musical context, one-dimensional noise may be of more interest, but higher dimensions are useful, for example to allow the sequence to vary over time, or to produce looping pseudo-noise (the *periodic helper provides this functionaity).

The *noise2, *noise3 and *noise4 functions are based on the example Java code (in the public domain) by Stefan Gustavson, with optimizations by Peter Eastman. You can read the paper (http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf) or see the original code (http://weber.itn.liu.se/~stegu/simplexnoise/SimplexNoise.java).

The functions return noise values in the range of -1 to 1 (approximately; it may sometimes go slightly outside this range). Simplex noise is repeatable, so for the same inputs it will produce the same outputs. If you want to "reseed" it, use a transform (offset, scaling or rotation) on the 2D or 3D (vector) arguments.

For 1D noise, just use *noise2 with a constant value for yin.

First code examples:

Class Methods

.new

An error will be thrown if you try to make an instance of this class. It has no instance data and all methods are class methods.

.periodic

Periodic one-dimensional Simplex noise.

Arguments:

x

The "time" (arbitary 1D parameter), typically from 0.0 to 1.0, at which to evaluate periodic noise. x outside the range of 0-1 will repeat.

offset

A scalar or vector of two values, used to offset the "origin" of the noise space. This can be used to provide a different noise "seed". Very small changes to the offset will provide small variations in the noise.

freqScale

Scaling of the noise space (effectively its "frequency"). Larger values will make the noise change direction more times in each cycle.

oct

How many octaves of noise to sum. This provides more random "detail". Useful range is generally from 1 to 8. Adding more octaves will increase calculation time.

.fBm2

Fractional (or fractal) Brownian motion (https://en.wikipedia.org/wiki/Fractional_Brownian_motion) noise in 2D, which performs of sum of increasingly higher-frequency octaves of 2D Simplex noise.

Arguments:

xin
yin

The 2D coordinates at which to evaluate the noise function.

oct

How many octaves of noise to sum. This provides more random "detail". Useful range is generally from 1 to 8. Adding more octaves will increase calculation time.

.fBm3

Fractional (or fractal) Brownian motion noise in 3D, which performs of sum of increasingly higher-frequency octaves of 3D Simplex noise.

Arguments:

xin
yin
zin

The 3D coordinates at which to evaluate the noise function.

oct

How many octaves of noise to sum. This provides more random "detail". Useful range is generally from 1 to 8. Adding more octaves will increase calculation time.

.fBm4

Fractional (or fractal) Brownian motion noise in 4D, which performs of sum of increasingly higher-frequency octaves of 4D Simplex noise.

Arguments:

xin
yin
zin
win

The 4D coordinates at which to evaluate the noise function.

oct

How many octaves of noise to sum. This provides more random "detail". Useful range is generally from 1 to 8. Adding more octaves will increase calculation time.

.noise2

A Simplex noise function in 2D. Takes a coordinate and returns a scalar "spatial noise" value.

Arguments:

xin
yin

The 2D coordinate at which to evaluate the noise function.

.noise3

A Simplex noise function in 3D. Takes a coordinate and returns a scalar "spatial noise" value.

Arguments:

xin
yin
zin

The 3D coordinate at which to evaluate the noise function.

.noise4

A Simplex noise function in 4D. Takes a coordinate and returns a scalar "spatial noise" value.

Arguments:

xin
yin
zin
win

The 4D coordinate at which to evaluate the noise function.

Instance Methods

None. Use the class methods, there is no need to create instances of Simplex class, since there is no instance-specific data.

Examples