Class NoiseCurlSampler
Computes curl noise from a scalar noise potential, producing divergence-free vector fields suitable for particle flow, smoke simulation, and fluid effects.
Inherited Members
Namespace: Scylla.Core.Util.Noise
Assembly: ScyllaCore.dll
Syntax
public sealed class NoiseCurlSampler
Remarks
2D curl noise uses central finite differences to compute the gradient of a scalar potential, then rotates it 90 degrees to produce a divergence-free flow field. This ensures particles following the field never converge or diverge, creating natural swirling patterns.
3D curl noise uses three decorrelated scalar potentials (via large irrational offsets) and computes the full curl vector via 12 noise evaluations.
Performance: 4 noise evaluations per 2D sample, 12 per 3D sample. Each evaluation may involve fractal octave loops if the noise settings include fractal layering. This is inherently expensive.
Constructors
NoiseCurlSampler(NoiseGenerator, float)
Creates a new NoiseCurlSampler bound to the specified noise generator.
Declaration
public NoiseCurlSampler(NoiseGenerator generator, float epsilon = 0.001)
Parameters
| Type | Name | Description |
|---|---|---|
| NoiseGenerator | generator | The noise generator to use for potential evaluation. |
| float | epsilon | The step size for finite difference approximation. Default is 0.001. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |
Methods
SampleCurl2D(float, float, NoiseSettings)
Samples 2D curl noise at the given coordinates, returning a divergence-free flow vector perpendicular to the scalar noise gradient at that point.
Declaration
public Vector2 SampleCurl2D(float x, float y, NoiseSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | X coordinate. |
| float | y | Y coordinate. |
| NoiseSettings | settings | Noise settings used to evaluate the underlying scalar potential field. Fractal layering (if configured) is applied to the potential evaluations, increasing the richness of the resulting flow field at the cost of additional evaluations. |
Returns
| Type | Description |
|---|---|
| Vector2 | A 2D divergence-free flow vector |
Remarks
Uses 4 noise evaluations (central differences in X and Y). The step size was specified
at construction time via the epsilon parameter. Smaller epsilon values produce
more accurate gradients but increase sensitivity to noise quantization.
SampleCurl3D(float, float, float, NoiseSettings)
Samples 3D curl noise at the given coordinates, returning a divergence-free flow vector computed as the curl of three decorrelated scalar potential functions.
Declaration
public Vector3 SampleCurl3D(float x, float y, float z, NoiseSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | X coordinate. |
| float | y | Y coordinate. |
| float | z | Z coordinate. |
| NoiseSettings | settings | Noise settings used to evaluate all three underlying scalar potential fields. Fractal layering (if configured) is applied to every potential evaluation, increasing the richness of the resulting flow field at the cost of additional evaluations. |
Returns
| Type | Description |
|---|---|
| Vector3 | A 3D divergence-free flow vector equal to
|
Remarks
Uses 12 noise evaluations (4 central differences per potential, 3 potentials).
The three potentials are decorrelated using large irrational coordinate offsets
(POTENTIAL_OFFSET_1 ≈ 31.34 and POTENTIAL_OFFSET_2 ≈ 47.72) to prevent
the three gradient components from aligning.