33 std::array<int, 512> _values;
36 float _persistence = 0.5f;
37 float _lacunarity = 2.0f;
38 float _frequency = 1.0f;
40 static float _fade(
float p_value,
Interpolation p_interpolation);
41 static float _lerp(
float p_minValue,
float p_maxValue,
float p_value);
42 static float _grad(
int p_hash,
float p_x);
43 static float _grad(
int p_hash,
float p_x,
float p_y);
44 static float _grad(
int p_hash,
float p_x,
float p_y,
float p_z);
46 void _reseed(
unsigned int p_seed);
48 float _noise1D(
float p_x)
const;
49 float _noise2D(
float p_x,
float p_y)
const;
50 float _noise3D(
float p_x,
float p_y,
float p_z)
const;
52 static float _fractal(
54 std::function<
float(
const Perlin &,
float,
float,
float)> p_noiseFunc,
80 void setSeed(
unsigned int p_seed);
133 float sample1D(
float p_x,
float p_min = 0,
float p_max = 1)
const;
142 float sample2D(
float p_x,
float p_y,
float p_min = 0,
float p_max = 1)
const;
152 float sample3D(
float p_x,
float p_y,
float p_z,
float p_min = 0,
float p_max = 1)
const;
Generates Perlin noise in 1D/2D/3D with configurable fractal parameters.
Definition spk_perlin.hpp:20
float sample2D(float p_x, float p_y, float p_min=0, float p_max=1) const
Samples 2D fractal noise.
Definition spk_perlin.cpp:214
float sample3D(float p_x, float p_y, float p_z, float p_min=0, float p_max=1) const
Samples 3D fractal noise.
Definition spk_perlin.cpp:231
void setSeed(unsigned int p_seed)
Reseeds the permutation table.
Definition spk_perlin.cpp:152
void setPersistence(float p_p)
Sets amplitude persistence between octaves.
Definition spk_perlin.cpp:162
const float & frequency() const
Returns base frequency.
Definition spk_perlin.cpp:192
void setInterpolation(Interpolation p_interp)
Sets the interpolation curve.
Definition spk_perlin.cpp:147
Interpolation
Selects smoothing curve applied between lattice points.
Definition spk_perlin.hpp:27
@ Linear
Simple linear blending.
Definition spk_perlin.hpp:28
@ SmoothStep
SmoothStep easing for softer transitions.
Definition spk_perlin.hpp:29
void setLacunarity(float p_l)
Sets frequency multiplier per octave.
Definition spk_perlin.cpp:167
float sample1D(float p_x, float p_min=0, float p_max=1) const
Samples 1D fractal noise.
Definition spk_perlin.cpp:197
void setFrequency(float p_f)
Sets base frequency.
Definition spk_perlin.cpp:172
const int & octaves() const
Returns octave count.
Definition spk_perlin.cpp:177
const float & lacunarity() const
Returns lacunarity.
Definition spk_perlin.cpp:187
Perlin(unsigned int p_seed=0, Perlin::Interpolation p_interp=Perlin::Interpolation::SmoothStep)
Constructs a Perlin generator with optional seed and interpolation.
Definition spk_perlin.cpp:141
const float & persistence() const
Returns persistence.
Definition spk_perlin.cpp:182
void setOctaves(int p_oct)
Sets octave count for fractal noise.
Definition spk_perlin.cpp:157