|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Ken Perlin's gradient-noise implicit function. More...
#include <EBGeometry_AnalyticDistanceFunctions.hpp>


Public Member Functions | |
| PerlinSDF ()=default | |
| Default constructor. Constructs a single-octave Perlin noise field with unit amplitude, unit frequency along all axes, and persistence 0.5. | |
| PerlinSDF (const T a_noiseAmplitude, const Vec3T< T > a_noiseFrequency, const T a_noisePersistence, const unsigned int a_noiseOctaves) noexcept | |
| Full constructor. | |
| PerlinSDF (const PerlinSDF &)=default | |
| Copy constructor. | |
| PerlinSDF (PerlinSDF &&)=default | |
| Move constructor. | |
| PerlinSDF & | operator= (const PerlinSDF &)=default |
| Copy assignment. | |
| PerlinSDF & | operator= (PerlinSDF &&)=default |
| Move assignment. | |
| ~PerlinSDF () override=default | |
| Destructor. | |
| T | signedDistance (const Vec3T< T > &a_point) const noexcept override |
| Signed distance function. Generates a noise value on [0, m_noiseAmplitude]. | |
| template<class URNG > | |
| void | shuffle (URNG &g) noexcept |
| Shuffle the permutation table with the provided uniform random number generator. | |
| std::array< int, 512 > & | getPermutationTable () noexcept |
| Get the internal permutation table. | |
Public Member Functions inherited from EBGeometry::SignedDistanceFunction< T > | |
| SignedDistanceFunction ()=default | |
| Default constructor. | |
| ~SignedDistanceFunction () override=default | |
| Destructor. | |
| T | value (const Vec3T< T > &a_point) const noexcept final |
| Implementation of ImplicitFunction::value; delegates to signedDistance(). | |
| virtual Vec3T< T > | normal (const Vec3T< T > &a_point, const T &a_delta) const noexcept |
| Compute the outward normal using central finite differences. | |
Public Member Functions inherited from EBGeometry::ImplicitFunction< T > | |
| ImplicitFunction ()=default | |
| Default constructor. | |
| virtual | ~ImplicitFunction ()=default |
| Default destructor. | |
| T | operator() (const Vec3T< T > &a_point) const noexcept |
| Call operator — alternative signature for the value function. | |
| template<class BV > | |
| BV | approximateBoundingVolumeOctree (const Vec3T< T > &a_initialLowCorner, const Vec3T< T > &a_initialHighCorner, const unsigned int a_maxTreeDepth, const T &a_safety=0.0) const |
| Compute an approximation to the bounding volume for the implicit surface using octree subdivision. | |
Protected Member Functions | |
| virtual T | lerp (const T t, const T a, const T b) const noexcept |
| Ken Perlin's linear interpolation helper. | |
| virtual T | fade (const T t) const noexcept |
| Ken Perlin's fade (smoothstep) function: 6t^5 - 15t^4 + 10t^3. | |
| T | grad (const int hash, const T x, const T y, const T z) const noexcept |
| Ken Perlin's gradient hash function. | |
| T | noise (const Vec3T< T > &a_point) const noexcept |
| Single-octave Perlin noise evaluation. | |
Protected Attributes | |
| Vec3T< T > | m_noiseFrequency = Vec3T<T>(T(1), T(1), T(1)) |
| Spatial noise frequency along each Cartesian axis. | |
| T | m_noiseAmplitude = T(1) |
| Noise amplitude (output scale). | |
| T | m_noisePersistence = T(0.5) |
| Per-octave amplitude decay factor. | |
| std::array< int, 512 > | m_permutationTable = {} |
| Integer hash permutation table (512 entries: [0..255] mirrored). | |
| unsigned int | m_noiseOctaves = 1U |
| Number of noise octaves. | |
Static Protected Attributes | |
| static constexpr std::array< int, 256 > | s_perlinPermutationTable |
| Ken Perlin's original 256-entry permutation table. | |
Ken Perlin's gradient-noise implicit function.
This class evaluates multi-octave Perlin noise at a 3-D point and returns the result as a scalar. It is not a true signed distance function (the gradient magnitude is not guaranteed to equal 1), but it can serve as a procedural displacement field when added to or subtracted from a conventional SDF.
The output of signedDistance is on the range [0, m_noiseAmplitude] for a single octave. Multiple octaves sum scaled contributions: each successive octave doubles the spatial frequency (controlled by m_noisePersistence dividing the frequency) and attenuates the amplitude by m_noisePersistence.
shuffle() explicitly before use. | T | Floating-point precision. |
|
inlinenoexcept |
Full constructor.
| [in] | a_noiseAmplitude | Noise amplitude (output scale). |
| [in] | a_noiseFrequency | Spatial frequency along each Cartesian axis. |
| [in] | a_noisePersistence | Per-octave amplitude decay factor. Clamped to [0, 1]. |
| [in] | a_noiseOctaves | Number of noise octaves. Clamped to >= 1. |
|
inlineprotectedvirtualnoexcept |
Ken Perlin's fade (smoothstep) function: 6t^5 - 15t^4 + 10t^3.
| [in] | t | Input in [0,1]. |
|
inlinenoexcept |
Get the internal permutation table.
|
inlineprotectednoexcept |
Ken Perlin's gradient hash function.
| [in] | hash | Hash value selecting one of 16 gradient directions. |
| [in] | x | x-component of the relative position. |
| [in] | y | y-component of the relative position. |
| [in] | z | z-component of the relative position. |
|
inlineprotectedvirtualnoexcept |
Ken Perlin's linear interpolation helper.
| [in] | t | Interpolation weight in [0,1]. |
| [in] | a | Start value. |
| [in] | b | End value. |
|
inlineprotectednoexcept |
Single-octave Perlin noise evaluation.
| [in] | a_point | Input point in noise space. |
|
default |
Copy assignment.
|
default |
Move assignment.
|
inlinenoexcept |
Shuffle the permutation table with the provided uniform random number generator.
Reseeds the 256-entry permutation table using std::shuffle and then mirrors it into the upper 256 entries. The URNG type must satisfy the C++ UniformRandomBitGenerator concept (e.g., std::mt19937).
| URNG | Uniform random number generator type (e.g., std::mt19937). |
| [in] | g | Uniform random number generator instance to drive the shuffle. |
|
inlineoverridevirtualnoexcept |
Signed distance function. Generates a noise value on [0, m_noiseAmplitude].
| [in] | a_point | Input point. |
Implements EBGeometry::SignedDistanceFunction< T >.
|
protected |
Integer hash permutation table (512 entries: [0..255] mirrored).
Default-constructed with all zeros (degenerate, constant-zero noise). Use the full constructor or shuffle() to populate with a real permutation.
|
staticconstexprprotected |
Ken Perlin's original 256-entry permutation table.
Used by the full constructor and shuffle() to seed m_permutationTable. Stored as a static constexpr member so it is available to subclasses without polluting the enclosing namespace.