Simplex Noise Library
Templated CPU implementation of simplex noise

view on
github

A C++11 implementation of simplex noise on the CPU, created for the purposes of learning and expanding.
The source for this library comes in 3 separate files: a header, a implementation file for templated functions, and an implementation file for nontemplated functions.
float
s and
double
s can be used without rewriting code.
The following functions are available in the SimplexNoise
API. Note that
many of the noise functions are very similar, usually just adding an additional point
component to the argument list, additional derivative output, or an octaves parameter.
The extended descriptions are minimized by default for ease of locating functions by name. Click the +/− or the function name to expand/shrink the description. (expand all  shrink all)
The SimplexNoise class is the primary noise generation class. Once instantiated, it can have its noise functions called to generate noise.
()
SimplexNoise<Float>
instance using the
default permutation table.Float : typename
(const unsigned char* perm...)
SimplexNoise<Float>
instance using the
default permutation table.Float : typename
perm : const unsigned char*
Float SimplexNoise<Float>.(Float x, Float* dx...)
x : Float
dx : Float*
Float
which will contain the noise function's
derivative after the function has returnedreturn : Float
Float SimplexNoise<Float>.(Float x, Float y, Float* dx, Float* dy...)
x : Float
y : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to yreturn : Float
Float SimplexNoise<Float>.(Float x, Float y, Float z...)
x : Float
y : Float
z : Float
return : Float
Float SimplexNoise<Float>.(Float x, Float y, Float z, Float* dx, Float* dy, Float* dy...)
x : Float
y : Float
z : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to ydy : Float*
Float
which will contain the noise function's
partial derivative with respect to zreturn : Float
Float SimplexNoise<Float>.(Float x, Float y, Float z, Float z...)
x : Float
y : Float
z : Float
z : Float
return : Float
Float SimplexNoise<Float>.(Float x, Float y, Float z, Float w, Float* dx, Float* dy, Float* dy, Float* dw...)
x : Float
y : Float
z : Float
w : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to ydy : Float*
Float
which will contain the noise function's
partial derivative with respect to zdw : Float*
Float
which will contain the noise function's
partial derivative with respect to wreturn : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float* dx...)
octaves : OctavesInt
x : Float
dx : Float*
Float
which will contain the noise function's
derivative after the function has returnedreturn : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y...)
octaves : OctavesInt
x : Float
y : Float
return : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y, Float* dx, Float* dy...)
octaves : OctavesInt
x : Float
y : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to yreturn : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y, Float z...)
octaves : OctavesInt
x : Float
y : Float
z : Float
return : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y, Float z, Float* dx, Float* dy, Float* dy...)
octaves : OctavesInt
x : Float
y : Float
z : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to ydy : Float*
Float
which will contain the noise function's
partial derivative with respect to zreturn : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y, Float z, Float z...)
octaves : OctavesInt
x : Float
y : Float
z : Float
z : Float
return : Float
Float SimplexNoise<Float>.(OctavesInt octaves, Float x, Float y, Float z, Float w, Float* dx, Float* dy, Float* dy, Float* dw...)
octaves : OctavesInt
x : Float
y : Float
z : Float
w : Float
dx : Float*
Float
which will contain the noise function's
partial derivative with respect to xdy : Float*
Float
which will contain the noise function's
partial derivative with respect to ydy : Float*
Float
which will contain the noise function's
partial derivative with respect to zdw : Float*
Float
which will contain the noise function's
partial derivative with respect to wreturn : Float
Float SimplexNoise<Float>.(Float maxRadius, Float power, int dimensions, const Float* position...)
maxRadius : Float
0.5
or 0.6
values typically used in simplex noise.power : Float
dimensions : int
position : const Float*
dimensions
values.return : Float
Source codes and binarys for 3 executables are included in this project. They are used for testing various functions and bruteforce solving noise function minimum/maximums.
test.exe is an application to test the 1 through 4 dimensional noise functions,
writing the output to a .pgm
image. It has the following command line syntax:
filename
– the output filename of the .pgm
file
width
– the width of the output file, in pixels
height
– the height of the output file, in pixels
scale
– the scaling factor for the noise function coordinates
dimensions
– the dimensions of the function to test.1
, 2
, 3
, or 4
.
octaves
– number of octaves to use
derivative
– the number of the derivative to output.0
outputs the noise function itself.1
outputs the first partial derivative.
demo.exe is an application to test the generic noise_n
function,
writing the output to a .pgm
image. It has the following command line syntax:
filename
– the output filename of the .pgm
file.""
, it will output to stdout
.
mode
– pgm output mode; either binary
or ascii
.
norm_mode
– normalization mode of the noise values.centered
will normalize around 0
.full
will normalize to the range [0, 1]
regardless of where the center is.width
– the width of the output file, in pixels
height
– the height of the output file, in pixels
scale
– the scaling factor for the noise function coordinates
max_radius
– the maximum distance squared from a simplex point that a contribution can be nonzero
power
– the exponent of the noise function's point contributions
dimensions
– the dimensions of the function to test.
octaves
– number of octaves to use
[x, y, z, w, ...]
– Optional starting values for the first coordinate.0
.
solver.exe is an application to bruteforce compute the maximum/minimum values of a noise function. It does this by selecting permutations of gradients and iterating over the points of a simplex, computing the noise function at each point.
This takes very long for the 4d case, but the minimum/maximum values will converge to a good approximation in a reasonable amount of time. Therefore, the execution can be interrupted to get a good approximate value.
show_every
– show output from every computation iteration.true
, output is shown for each step. If false
, output is only displayed
when a minimum/maximum update occurs.
threads
– number of threads to use.0
, it automatically uses the number of cores on the system.
dimensions
– number of dimensions to test for.2
, 3
, or 4
.
sample_points
– order of the number of points to sample.sample_points_large
– order of the number of points to sample when a minimum/maximum update occurs.