public class SeededNoise extends java.lang.Object implements Noise.Noise2D, Noise.Noise3D, Noise.Noise4D, Noise.Noise5D, Noise.Noise6D
Noise.seamless2D(double[][], long, int, Noise.Noise4D)
and/or
Noise.seamless3D(double[][][], long, int, Noise.Noise6D)
. All functions can take a long seed that should
significantly change the pattern of noise produced. Incorporates code from Joise; the full library is available at
https://github.com/SudoPlayGames/Joise , and this class adds rather significant optimization in a few methods,
especially 6D noise. Joise is derived from the Accidental Noise Library, available in C++ at
http://accidentalnoise.sourceforge.net/index.html . Both Joise and ANL have many features that SquidLib has not (yet)
incorporated, but now that SquidLib has seamless noise, that's a nice feature that would have needed Joise before.
This also supplies 5D noise, which doesn't have an immediate application like taking 6D noise and making 3D seamless
noise, but still has plenty of uses. This
world GIF was made using 5D noise, for instance, using a cycle through the 4th and 5th dimensions to alter the
globe in a way that loops. You'd probably find yourself mostly using 2D through 4D, though, with 4D useful for 3D
shapes that change linearly over time.Modifier and Type | Field and Description |
---|---|
long |
defaultSeed |
protected static double |
F2 |
protected static double |
F3 |
protected static double |
F4 |
protected static double |
F5 |
protected static double |
F6 |
protected static double |
G2 |
protected static double |
G3 |
protected static double |
G4 |
protected static double |
G5 |
protected static double |
G6 |
static double[] |
grad2d
256 2-element gradient vectors formed from the cos and sin of increasing multiples of the inverse of phi, the
golden ratio, while also adding increasing multiples of 2/3 of the reciprocal of
Math.E . |
protected static double[] |
grad3d |
protected static double[] |
grad4d |
protected static double[] |
grad5d
This gradient vector array was pseudo-randomly generated after a lot of rejection sampling.
|
protected static double[] |
grad6d |
protected static double |
H2 |
static SeededNoise |
instance |
protected static double |
LIMIT4 |
protected static double |
LIMIT5 |
protected static double |
LIMIT6 |
protected static int[] |
SIMPLEX_4D
Used by
noise(double, double, double, double, long) to look up the vertices of the 4D triangle analogue. |
Constructor and Description |
---|
SeededNoise() |
SeededNoise(long seed) |
Modifier and Type | Method and Description |
---|---|
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 |
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,
double u,
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) |
protected static double |
gradCoord2D(long seed,
int x,
int y,
double xd,
double yd) |
protected static double |
gradCoord3D(long seed,
int x,
int y,
int z,
double xd,
double yd,
double zd)
Computes the hash for a 3D int point and its dot product with a 3D double point as one step.
|
protected static double |
gradCoord5D(long seed,
int x,
int y,
int z,
int w,
int u,
double xd,
double yd,
double zd,
double wd,
double ud) |
static double |
noise(double x,
double y,
double z,
double w,
double u,
double v,
long seed) |
static double |
noise(double x,
double y,
double z,
double w,
double u,
long seed)
Thanks to Mark A.
|
static double |
noise(double x,
double y,
double z,
double w,
long seed) |
static double |
noise(double x,
double y,
double z,
long seed) |
static double |
noise(double x,
double y,
long seed) |
public long defaultSeed
public static final SeededNoise instance
protected static final int[] SIMPLEX_4D
noise(double, double, double, double, long)
to look up the vertices of the 4D triangle analogue.protected static final double F2
protected static final double G2
protected static final double H2
protected static final double F3
protected static final double G3
protected static final double F4
protected static final double G4
protected static final double LIMIT4
protected static final double F5
protected static final double G5
protected static final double LIMIT5
protected static final double F6
protected static final double G6
protected static final double LIMIT6
public static final double[] grad2d
Math.E
. This produces
a sequence with remarkably low overlap possible from nearby angles, distributed nicely around the unit circle.
For i from 1 to 256 inclusive, this gets the cosine and sine of an angle in radians of
0.61803398874989484820458683436563811772 * i + (i / (1.5 * 2.7182818284590452354))
. This is expected to
be accessed using an 8-bit int (depending on how you got your int, the normal way to get 8 bits would be
index & 255
), but smaller numbers should also work down to about 4 bits (typically using
index & 15
).protected static final double[] grad3d
protected static final double[] grad4d
protected static final double[] grad5d
MathExtras.probit(double)
and then
normalizing the resulting 5D vector. Because the R5 sequence is quasi-random (it only very rarely returns clumps
of points that are close-together in both the sequence and in space), the Gaussian points were more likely to be
quasi-random as well, and far fewer point sets needed to be rejected.protected static final double[] grad6d
protected static double gradCoord2D(long seed, int x, int y, double xd, double yd)
protected static double gradCoord3D(long seed, int x, int y, int z, double xd, double yd, double zd)
seed
- x
- y
- z
- xd
- yd
- zd
- protected static double gradCoord5D(long seed, int x, int y, int z, int w, int u, double xd, double yd, double zd, double wd, double ud)
public double getNoise(double x, double y)
getNoise
in interface Noise.Noise2D
public double getNoise(double x, double y, double z)
getNoise
in interface Noise.Noise3D
public double getNoise(double x, double y, double z, double w)
getNoise
in interface Noise.Noise4D
public double getNoise(double x, double y, double z, double w, double u)
getNoise
in interface Noise.Noise5D
public double getNoise(double x, double y, double z, double w, double u, double v)
getNoise
in interface Noise.Noise6D
public double getNoiseWithSeed(double x, double y, long seed)
getNoiseWithSeed
in interface Noise.Noise2D
public double getNoiseWithSeed(double x, double y, double z, long seed)
getNoiseWithSeed
in interface Noise.Noise3D
public double getNoiseWithSeed(double x, double y, double z, double w, long seed)
getNoiseWithSeed
in interface Noise.Noise4D
public double getNoiseWithSeed(double x, double y, double z, double w, double u, long seed)
getNoiseWithSeed
in interface Noise.Noise5D
public double getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)
getNoiseWithSeed
in interface Noise.Noise6D
public static double noise(double x, double y, long seed)
public static double noise(double x, double y, double z, long seed)
public static double noise(double x, double y, double z, double w, long seed)
public static double noise(double x, double y, double z, double w, double u, long seed)
x
- x coordinatey
- y coordinatez
- z coordinatew
- w coordinate (4th dimension)u
- u coordinate (5th dimension)seed
- long value that should completely change the noise if it changes even slightlypublic static double noise(double x, double y, double z, double w, double u, double v, long seed)
Copyright © Eben Howard 2012–2022. All rights reserved.