warp.curlnoise#
- warp.curlnoise( ) vec2f#
Kernel
Python
Differentiable
Sample a divergence-free 2D vector field derived from Perlin noise.
Its continuous flow preserves area, although numerical advection may not.
Octave
iuses frequencylacunarity ** iand weightgain ** i. Withlacunarity > 1and0 < gain < 1, later octaves add finer, weaker detail. Contributions may cancel, so magnitude is not monotonic in the octave controls. Scale the coordinate for feature size and the result for speed.stateselects the field and is not advanced. For a given Warp version and device backend, results are deterministic for fixed inputs. Exact values may differ between CPU and CUDA or change between Warp versions. This function is differentiable with respect to the coordinate. Currently,lacunarityandgainreceive no gradient.- Parameters:
state – RNG state that selects the noise field (see
rand_init()); never advanced.xy – Coordinate to sample.
octaves – Number of noise octaves to sum. Zero returns a zero vector.
lacunarity – Frequency multiplier between successive octaves.
gain – Amplitude multiplier between successive octaves.
- Returns:
A rotated Perlin-noise gradient at
xy. The resulting vector field is analytically divergence-free. The vector is not normalized.
Example
@wp.kernel def advect(seed: int, positions: wp.array[wp.vec2], dt: float): tid = wp.tid() state = wp.rand_init(seed) positions[tid] = positions[tid] + wp.curlnoise(state, positions[tid]) * dt positions = wp.array([[0.5, 0.5], [1.25, 2.0]], dtype=wp.vec2) wp.launch(advect, dim=len(positions), inputs=[42, positions, 0.1])
- warp.curlnoise( ) vec3f
Kernel
Python
Differentiable
Sample a divergence-free 3D vector field derived from Perlin noise.
See
curlnoise()for shared behavior, restrictions, and a usage example.- Parameters:
state – RNG state that selects the noise field (see
rand_init()); never advanced.xyz – Coordinate to sample.
octaves – Number of noise octaves to sum. Zero returns a zero vector.
lacunarity – Frequency multiplier between successive octaves.
gain – Amplitude multiplier between successive octaves.
- Returns:
A
warp.vec3containing the spatial curl of three Perlin-noise potentials atxyz. The resulting vector field is divergence-free. The vector is not normalized.
- warp.curlnoise( ) vec3f
Kernel
Python
Differentiable
Sample a divergence-free 3D vector field that also varies along a fourth axis.
The fourth input axis parametrizes the field and is commonly used as time. See
curlnoise()for shared behavior, restrictions, and a usage example.- Parameters:
state – RNG state that selects the noise field (see
rand_init()); never advanced.xyzt – Coordinate to sample, with the fourth component usually time.
octaves – Number of noise octaves to sum. Zero returns a zero vector.
lacunarity – Frequency multiplier between successive octaves.
gain – Amplitude multiplier between successive octaves.
- Returns:
A
warp.vec3containing the spatial curl of three Perlin-noise potentials atxyzt. The vector field is divergence-free in the first three axes. The vector is not normalized.