Package squidpony.squidmath
Class FoamNoise
java.lang.Object
squidpony.squidmath.FoamNoise
- All Implemented Interfaces:
Noise.Noise2D
,Noise.Noise3D
,Noise.Noise4D
,Noise.Noise6D
public class FoamNoise extends Object implements Noise.Noise2D, Noise.Noise3D, Noise.Noise4D, Noise.Noise6D
An unusual continuous noise generator that tends to produce organic-looking forms, currently supporting 2D, 3D, 4D
and 6D. Produces noise values from -1.0 inclusive to 1.0 exclusive. Typically needs fewer octaves than the Simplex
option in FastNoise to produce roughly comparable quality, but it also has about a third the speed. A useful property
of FoamNoise is how its visual "character" doesn't change much as dimensions are added; whereas 6D simplex noise
tends to separate into "surflets" separated by spans of 0, and higher dimensions of simplex only have larger such
spans, FoamNoise seems to stay approximately as coherent in 2D, 3D, and 4D. Verifying this claim about FoamNoise is
not easy, but it makes sense intuitively because of how this generator works. Simplex noise in N dimensions relies on
a lattice of N-simplices (such as triangles in 2D or tetrahedra in 3D) and evaluates the noise at a point by hashing
each of the N+1 vertices, looking up a gradient vector for each vertex from a pre-calculated array, and combining the
gradient vectors based on proximity of the evaluated point to each vertex. FoamNoise in N dimensions is not nearly as
complex; it relies on making N+1 averaged calls to N-dimensional value noise, each call using a rotated (and
potentially skewed) set of axes, with each call's result also affecting the inputs to the next call (domain warping).
Value noise uses a cubic lattice or its hypercube equivalent in higher dimensions, which seems to be more "stable" as
dimensionality increases, and the number of value noise calls increases at the same rate as simplex noise adds
gradient vectors. Averaging more calls causes the distribution of the noise to gradually approach Gaussian (biased
toward results in the center of the range), but adjustments this does at the end counteract this well enough.
It's encouraged to experiment with the lacunarity parameter in
2D FoamNoise, one octave, 2D FoamNoise, one octave colorized, 2D FoamNoise, two octaves colorized (note fewer peaks and valleys), 3D FoamNoise animated over time, one octave colorized, 3D FoamNoise animated over time, two octaves colorized, 4D FoamNoise animated over time, one octave colorized, 4D FoamNoise animated over time, two octaves colorized, 6D FoamNoise animated over time, one octave colorized, 6D FoamNoise animated over time, two octaves colorized, World map made using FoamNoise.
It's encouraged to experiment with the lacunarity parameter in
Noise.Layered3D
and similar classes if you use
one of those variants, which also probably needs adjustments to frequency. Changing lacunarity wit multiple octaves
can be useful to edit how tightly the noise clumps together. FoamNoise tends to look about the same with 3 octaves as
it does with 4 octaves; for perceived quality, the returns seem to diminish quickly from added octaves. This isn't
accurate for all frequencies, so you should definitely run through your options for what kinds of noise look good for
a particular scenario. Mixing Simplex and Foam noise can produce a good water effect when applied to grid cells.
2D FoamNoise, one octave, 2D FoamNoise, one octave colorized, 2D FoamNoise, two octaves colorized (note fewer peaks and valleys), 3D FoamNoise animated over time, one octave colorized, 3D FoamNoise animated over time, two octaves colorized, 4D FoamNoise animated over time, one octave colorized, 4D FoamNoise animated over time, two octaves colorized, 6D FoamNoise animated over time, one octave colorized, 6D FoamNoise animated over time, two octaves colorized, World map made using FoamNoise.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description static double
foamNoise(double x, double y, double z, double w, double u, double v, int seed)
static double
foamNoise(double x, double y, double z, double w, int seed)
static double
foamNoise(double x, double y, double z, int seed)
static double
foamNoise(double x, double y, int seed)
double
getNoise(double x, double y)
double
getNoise(double x, double y, double z)
double
getNoise(double x, double y, double z, double w)
double
getNoise(double x, double y, double z, double w, double u, double v)
double
getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)
double
getNoiseWithSeed(double x, double y, double z, double w, long seed)
double
getNoiseWithSeed(double x, double y, double z, long seed)
double
getNoiseWithSeed(double x, double y, long seed)
-
Field Details
-
Constructor Details
-
Method Details
-
foamNoise
-
foamNoise
-
foamNoise
-
foamNoise
public static double foamNoise(double x, double y, double z, double w, double u, double v, int seed) -
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise2D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise2D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise3D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise3D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise4D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise4D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise6D
-
getNoiseWithSeed
public double getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise6D
-