11 #include "../Vector3.h"
34 return a_Min + std::abs(
IntNoise2D(a_X, a_Y)) * (a_Max - a_Min);
81 int a_SizeX,
int a_SizeY,
90 int a_SizeX,
int a_SizeY,
int a_SizeZ,
111 int * a_Same,
int & a_NumSame
132 int a_SizeX,
int a_SizeY,
141 int a_SizeX,
int a_SizeY,
int a_SizeZ,
159 return a_T * a_T * a_T * (a_T * (a_T * 6 - 15) + 10);
165 int hash = a_Hash % 16;
167 NOISE_DATATYPE v = (hash < 4) ? a_Y : (((hash == 12) || (hash == 14)) ? a_X : a_Z);
168 return (((hash & 1) == 0) ? u : -u) + (((hash & 2) == 0) ? v : -v);
189 int x = ((a_X *
m_Seed) << 13) ^ a_X;
190 return (1 -
static_cast<NOISE_DATATYPE>((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824);
200 int n = a_X + a_Y * 57 +
m_Seed * 57 * 57;
202 return (1 -
static_cast<NOISE_DATATYPE>((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824);
212 int n = a_X + a_Y * 57 + a_Z * 57 * 57 +
m_Seed * 57 * 57 * 57;
215 static_cast<NOISE_DATATYPE>((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f
235 int x = ((a_X *
m_Seed) << 13) ^ a_X;
236 return ((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff);
245 int n = a_X + a_Y * 57 +
m_Seed * 57 * 57;
247 return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
256 int n = a_X + a_Y * 57 + a_Z * 57 * 57 +
m_Seed * 57 * 57 * 57;
258 return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
281 return ((P * a_Pct + Q) * a_Pct + R) * a_Pct + S;
292 return a_A * (1 - f) + a_B * f;
301 return a_A * (1 - a_Pct) + a_B * a_Pct;
326 return a_Val1 + (a_Val2 - a_Val1) * a_Ratio;
344 return Lerp(a_Val1, a_Val2, a_Ratio);
cOctavedNoise< cRidgedNoise< cCubicNoise > > cRidgedMultiNoise
NOISE_DATATYPE ClampedLerp(NOISE_DATATYPE a_Val1, NOISE_DATATYPE a_Val2, NOISE_DATATYPE a_Ratio)
Linearly interpolates between two values, clamping the ratio to [0, 1] first.
void Debug2DNoise(const NOISE_DATATYPE *a_Array, size_t a_SizeX, size_t a_SizeY, const AString &a_FileNameBase, NOISE_DATATYPE a_Coeff=32)
Exports the noise array into a file.
NOISE_DATATYPE Lerp(NOISE_DATATYPE a_Val1, NOISE_DATATYPE a_Val2, NOISE_DATATYPE a_Ratio)
Linearly interpolates between two values.
float NOISE_DATATYPE
The datatype used by all the noise generators.
cOctavedNoise< cCubicNoise > cPerlinNoise
void Debug3DNoise(const NOISE_DATATYPE *a_Array, size_t a_SizeX, size_t a_SizeY, size_t a_SizeZ, const AString &a_FileNameBase, NOISE_DATATYPE a_Coeff=32)
Exports the noise array into a set of files, ordered by XY and XZ.
static NOISE_DATATYPE CubicInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_C, NOISE_DATATYPE a_D, NOISE_DATATYPE a_Pct)
int IntNoise1DInt(int a_X) const
static NOISE_DATATYPE CosineInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct)
NOISE_DATATYPE CosineNoise1D(NOISE_DATATYPE a_X) const
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
NOISE_DATATYPE IntNoise2D(int a_X, int a_Y) const
NOISE_DATATYPE CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const
int IntNoise3DInt(int a_X, int a_Y, int a_Z) const
int IntNoise2DInt(int a_X, int a_Y) const
NOISE_DATATYPE SmoothNoise1D(int a_X) const
static NOISE_DATATYPE LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct)
NOISE_DATATYPE LinearNoise1D(NOISE_DATATYPE a_X) const
NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const
NOISE_DATATYPE IntNoise2DInRange(int a_X, int a_Y, float a_Min, float a_Max) const
NOISE_DATATYPE IntNoise1D(int a_X) const
NOISE_DATATYPE CubicNoise1D(NOISE_DATATYPE a_X) const
void Generate3D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ) const
Fills a 3D array with the values of the noise.
cNoise m_Noise
Noise used for integral random values.
cCubicNoise(int a_Seed)
Creates a new instance with the specified seed.
void CalcFloorFrac(int a_Size, NOISE_DATATYPE a_Start, NOISE_DATATYPE a_End, int *a_Floor, NOISE_DATATYPE *a_Frac, int *a_Same, int &a_NumSame) const
Calculates the integral and fractional parts along one axis.
void Generate2D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY) const
Fills a 2D array with the values of the noise.
static const int MAX_SIZE
Maximum size of each dimension of the query arrays.
Improved noise, as described by Ken Perlin: https://mrl.nyu.edu/~perlin/paper445.pdf Implementation a...
void Generate3D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ) const
Fills a 3D array with the values of the noise.
cImprovedNoise(int a_Seed)
Constructs a new instance of the noise obbject.
NOISE_DATATYPE GetValueAt(int a_X, int a_Y, int a_Z)
Returns the value at the specified integral coords.
static NOISE_DATATYPE Fade(NOISE_DATATYPE a_T)
Calculates the fade curve, 6 * t^5 - 15 * t^4 + 10 * t^3.
int m_Perm[512]
The permutation table used by the noise function.
void Generate2D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY) const
Fills a 2D array with the values of the noise.
static NOISE_DATATYPE Grad(int a_Hash, NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z)
Returns the gradient value based on the hash.