Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::Perlin Class Reference

Generates Perlin noise in 1D/2D/3D with configurable fractal parameters. More...

#include <spk_perlin.hpp>

Collaboration diagram for spk::Perlin:
Collaboration graph

Public Types

enum class  Interpolation { Linear , SmoothStep }
 Selects smoothing curve applied between lattice points. More...

Public Member Functions

 Perlin (unsigned int p_seed=0, Perlin::Interpolation p_interp=Perlin::Interpolation::SmoothStep)
 Constructs a Perlin generator with optional seed and interpolation.
void setInterpolation (Interpolation p_interp)
 Sets the interpolation curve.
void setSeed (unsigned int p_seed)
 Reseeds the permutation table.
void setOctaves (int p_oct)
 Sets octave count for fractal noise.
void setPersistence (float p_p)
 Sets amplitude persistence between octaves.
void setLacunarity (float p_l)
 Sets frequency multiplier per octave.
void setFrequency (float p_f)
 Sets base frequency.
const int & octaves () const
 Returns octave count.
const float & persistence () const
 Returns persistence.
const float & lacunarity () const
 Returns lacunarity.
const float & frequency () const
 Returns base frequency.
float sample1D (float p_x, float p_min=0, float p_max=1) const
 Samples 1D fractal noise.
float sample2D (float p_x, float p_y, float p_min=0, float p_max=1) const
 Samples 2D fractal noise.
float sample3D (float p_x, float p_y, float p_z, float p_min=0, float p_max=1) const
 Samples 3D fractal noise.

Detailed Description

Generates Perlin noise in 1D/2D/3D with configurable fractal parameters.

spk::Perlin noise(42);
float v = noise.sample2D(1.2f, 3.4f, -1.f, 1.f);
Generates Perlin noise in 1D/2D/3D with configurable fractal parameters.
Definition spk_perlin.hpp:20

Member Enumeration Documentation

◆ Interpolation

enum class spk::Perlin::Interpolation
strong

Selects smoothing curve applied between lattice points.

Enumerator
Linear 

Simple linear blending.

SmoothStep 

SmoothStep easing for softer transitions.

Constructor & Destructor Documentation

◆ Perlin()

spk::Perlin::Perlin ( unsigned int p_seed = 0,
Perlin::Interpolation p_interp = Perlin::Interpolation::SmoothStep )

Constructs a Perlin generator with optional seed and interpolation.

Parameters
p_seedRandom seed used for the permutation table.
p_interpInterpolation mode used between lattice points.
Here is the caller graph for this function:

Member Function Documentation

◆ frequency()

const float & spk::Perlin::frequency ( ) const

Returns base frequency.

Returns
Reference to the base frequency.

◆ lacunarity()

const float & spk::Perlin::lacunarity ( ) const

Returns lacunarity.

Returns
Reference to the lacunarity factor.

◆ octaves()

const int & spk::Perlin::octaves ( ) const

Returns octave count.

Returns octave count.

Returns
Reference to the configured octave count.

◆ persistence()

const float & spk::Perlin::persistence ( ) const

Returns persistence.

Returns
Reference to the persistence factor.

◆ sample1D()

float spk::Perlin::sample1D ( float p_x,
float p_min = 0,
float p_max = 1 ) const

Samples 1D fractal noise.

Parameters
p_xPosition.
p_minOutput min range.
p_maxOutput max range.
Returns
Noise value clamped to [p_min, p_max].
Here is the call graph for this function:

◆ sample2D()

float spk::Perlin::sample2D ( float p_x,
float p_y,
float p_min = 0,
float p_max = 1 ) const

Samples 2D fractal noise.

Parameters
p_xX position.
p_yY position.
p_minOutput min range.
p_maxOutput max range.
Returns
Noise value clamped to [p_min, p_max].
Here is the call graph for this function:

◆ sample3D()

float spk::Perlin::sample3D ( float p_x,
float p_y,
float p_z,
float p_min = 0,
float p_max = 1 ) const

Samples 3D fractal noise.

Parameters
p_xX position.
p_yY position.
p_zZ position.
p_minOutput min range.
p_maxOutput max range.
Returns
Noise value clamped to [p_min, p_max].
Here is the call graph for this function:

◆ setFrequency()

void spk::Perlin::setFrequency ( float p_f)

Sets base frequency.

Parameters
p_fFrequency.

◆ setInterpolation()

void spk::Perlin::setInterpolation ( Interpolation p_interp)

Sets the interpolation curve.

Parameters
p_interpLinear or SmoothStep.

◆ setLacunarity()

void spk::Perlin::setLacunarity ( float p_l)

Sets frequency multiplier per octave.

Parameters
p_lLacunarity factor.

◆ setOctaves()

void spk::Perlin::setOctaves ( int p_oct)

Sets octave count for fractal noise.

Parameters
p_octNumber of octaves.

◆ setPersistence()

void spk::Perlin::setPersistence ( float p_p)

Sets amplitude persistence between octaves.

Parameters
p_pPersistence factor.

◆ setSeed()

void spk::Perlin::setSeed ( unsigned int p_seed)

Reseeds the permutation table.

Parameters
p_seedSeed value.

The documentation for this class was generated from the following files:
  • includes/structure/math/spk_perlin.hpp
  • srcs/structure/math/spk_perlin.cpp