Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32.Noise.Simplex🞂SimplexUnit

GR32.Noise.Simplex

Provides smooth multi-dimensional Simplex Noise evaluation (2D, 3D, and 4D) for procedural textures, animations, and vector fields.

Description ​

The GR32.Noise.Simplex unit implements Ken Perlin's Simplex Noise algorithm for 2D, 3D, and 4D evaluation spaces. It provides the TSimplexNoise class, offering fast, smooth, pseudo-random continuous gradient noise with reduced computational overhead and visually superior isotropic isotropy compared to traditional grid-based Perlin noise.

Common Use Cases ​

  1. Procedural Texture Generation: Synthesizing natural patterns such as clouds, smoke, marble, wood grain, fire, and liquid surfaces without visible grid artifacts or directional bias.
  2. Terrain & Heightmap Generation: Creating continuous landscape elevation maps and heightfields across 2D spatial coordinates.
  3. Organic Motion & Particle Swarms: Driving organic motion in 2D or 3D vector fields where 3D or 4D noise (using time t as an extra dimension) produces smoothly evolving forces over time.
  4. Domain Warping & Distortion: Displacing spatial coordinates (x,y) prior to sampling other patterns or images to simulate turbulence, rippling water, or heat haze.

Mathematical Background ​

Standard classical Perlin noise divides space into a hypercubic grid (N-dimensional cubes). In N dimensions, a hypercube has 2N vertices, causing the computational complexity of classical noise to scale exponentially as O(2N). Consequently, sampling classical 3D noise requires evaluating 8 corners, while 4D noise requires evaluating 16 corners.

Simplex noise replaces hypercubic grids with a simplical grid (tessellation composed of N-dimensional simplices):

  • In 2D, a simplex is an equilateral triangle (3 vertices).
  • In 3D, a simplex is a tetrahedron (4 vertices).
  • In 4D, a simplex is a 5-cell / pentatope (5 vertices).

Because an N-dimensional simplex has only N+1 vertices, the computational complexity of Simplex noise scales as O(N2), making higher-dimensional sampling (3D and 4D) significantly faster.

1. Coordinate Space Skewing and Unskewing ​

To partition space into simplices, the input coordinate vector x=(x1,x2,…,xn) is transformed from standard Euclidean space to a skewed simplical space using a skew factor Fn:

s=(∑i=1nxi)⋅Fnxi′=xi+s,where Fn=n+1−1n

The cell coordinates in skewed space are determined by taking the floor values: ik=⌊xk′⌋. To calculate the unskewed displacement vector from the cell origin back to Euclidean space, an unskewing factor Gn is applied:

t=(∑i=1nik)⋅Gnxk=ik−t,where Gn=1−1n+1n

The exact skew and unskew constants for 2D, 3D, and 4D spaces implemented in TSimplexNoise are:

Dimension NSkew Factor FnUnskew Factor GnSimplex ShapeVertices (N+1)
2DF2=3−12≈0.3660254038G2=3−36≈0.2113248654Equilateral Triangle3
3DF3=13≈0.3333333333G3=16≈0.1666666667Tetrahedron4
4DF4=5−14≈0.3090169944G4=5−520≈0.13819660115-Cell (Pentatope)5

2. Simplex Traversal & Gradient Kernel Summation ​

  1. Cell Partitioning: By comparing relative magnitudes of fractional displacements (e.g. dx>dy>dz), the algorithm determines the precise simplex traversal order through the N+1 corners of the containing simplex.
  2. Pseudo-Random Gradient Hashing: Each vertex index is hashed through a seed-based 512-byte permutation table (FPerm) to look up a unit gradient vector gk.
  3. Distance Attenuation Radial Kernel: For each vertex k, the distance vector dxk from the vertex to the evaluation point is calculated in unskewed Euclidean space. The contribution nk of vertex k is governed by a radially symmetric polynomial kernel:
tk=max(0,r2−|dxk|2)nk=tk4⋅(gk⋅dxk)

where r2=0.5 for 2D and 3D (or 0.6 for 4D).

Summing the corner contributions n=∑k=0Nnk yields a smooth C2 continuous scalar value scaled within the range [−1.0,1.0].