Package squidpony.squidmath
Class ClassicNoise
java.lang.Object
squidpony.squidmath.ClassicNoise
- All Implemented Interfaces:
Noise.Noise2D,Noise.Noise3D,Noise.Noise4D,Noise.Noise6D
public class ClassicNoise extends Object implements Noise.Noise2D, Noise.Noise3D, Noise.Noise4D, Noise.Noise6D
"Classic Perlin" noise, as opposed to the Simplex Noise also created by Ken Perlin (which is produced by
ClassicNoise is a good choice with parts of
SeededNoise; both can be produced by FastNoise).
This noise can in theory be scaled up to arbitrary dimensions, but in practice uses unreasonably hefty amounts of
memory when dimensionality exceeds 10 or so, since it needs to hash Math.pow(2, dimensionality) points per
sample of noise, which involves over a thousand points in 10 dimensions and over a million points in 20 dimensions.
For that reason, it's limited to 6D noise here, and also implements 2D, 3D, and 4D. Its performance is surprisingly
good at 2D, 3D, and 4D but trails off quickly at 6D. Its quality is worse than normal simplex noise in 2D, but you
can use JitterNoise (which takes the same algorithm and distorts the grid pseudo-randomly) to get unusually
high-quality 2D noise. The quality is actually quite good in 4D and higher; there's often some rhythmic patterns in
3D when time is z, but with 4 or 6 dimensions this can have fewer artifacts than Simplex in the same dimension. The
3D and higher dimensionality versions don't seem to need jitter to avoid grid artifacts, at least most of the time.
This uses different gradient vectors than what was recommended in the "Improved Perlin Noise" paper, since the ones
this uses avoid 45-degree angular artifacts in all dimensions implemented.
ClassicNoise is a good choice with parts of
WorldMapGenerator that need a
Noise3D implementation, and it tends to about as fast as SeededNoise in 3D. It is not recommended for 2D
use; prefer JitterNoise or SeededNoise for that. You can also use FastNoise with
FastNoise.PERLIN_FRACTAL as the noiseType if you primarily want to use float input and get float output.
If you want higher-dimensional noise than this supports, you can use PhantomNoise.-
Field Summary
Fields Modifier and Type Field Description static ClassicNoiseinstancelongseed -
Constructor Summary
Constructors Constructor Description ClassicNoise()ClassicNoise(long seed) -
Method Summary
Modifier and Type Method Description doublegetNoise(double x, double y)doublegetNoise(double x, double y, double z)doublegetNoise(double x, double y, double z, double w)doublegetNoise(double x, double y, double z, double w, double u, double v)doublegetNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)doublegetNoiseWithSeed(double x, double y, double z, double w, long seed)doublegetNoiseWithSeed(double x, double y, double z, long seed)doublegetNoiseWithSeed(double x, double y, long seed)protected static doublegradCoord2D(long seed, int x, int y, double xd, double yd)protected static doublegradCoord3D(long seed, int x, int y, int z, double xd, double yd, double zd)protected static doublegradCoord4D(long seed, int x, int y, int z, int w, double xd, double yd, double zd, double wd)protected static doublegradCoord6D(long seed, int x, int y, int z, int w, int u, int v, double xd, double yd, double zd, double wd, double ud, double vd)
-
Field Details
-
Constructor Details
-
ClassicNoise
public ClassicNoise() -
ClassicNoise
-
-
Method Details
-
gradCoord2D
-
gradCoord3D
protected static double gradCoord3D(long seed, int x, int y, int z, double xd, double yd, double zd) -
gradCoord4D
protected static double gradCoord4D(long seed, int x, int y, int z, int w, double xd, double yd, double zd, double wd) -
gradCoord6D
protected static double gradCoord6D(long seed, int x, int y, int z, int w, int u, int v, double xd, double yd, double zd, double wd, double ud, double vd) -
getNoise
- Specified by:
getNoisein interfaceNoise.Noise2D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise2D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise3D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise3D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise4D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise4D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise6D
-
getNoiseWithSeed
public double getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)- Specified by:
getNoiseWithSeedin interfaceNoise.Noise6D
-