warp.noise#

warp.noise(state: uint32, x: float32) float#
  • Kernel

  • Python

  • Differentiable

Sample 1D non-periodic Perlin noise.

Samples a smooth, deterministic field on an integer lattice with one cell per input unit. state selects the field and is not advanced. Scale the coordinate to change feature size and the result to change amplitude.

The field is differentiable with respect to the coordinate. 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. Use pnoise() for periodic noise.

When a coordinate component’s magnitude reaches 2^23 (about 8.4e6), float32 spacing is at least one input unit, so the field may lose variation. Coordinate components must currently remain within the signed 32-bit lattice-index range.

Parameters:
  • state – RNG state that selects the noise field (see rand_init()); never advanced.

  • x – Coordinate to sample. One noise feature spans one unit.

Returns:

The noise value at x. Values across the field are centered on zero.

Example

@wp.kernel
def sample_noise(seed: int, coords: wp.array[float], values: wp.array[float]):
    tid = wp.tid()
    state = wp.rand_init(seed)
    values[tid] = wp.noise(state, coords[tid])

coords = wp.array([0.5, 2.25, 4.75], dtype=float)
values = wp.zeros(len(coords), dtype=float)

wp.launch(sample_noise, dim=len(coords), inputs=[42, coords], outputs=[values])
warp.noise(state: uint32, xy: vec2f) float
  • Kernel

  • Python

  • Differentiable

Sample 2D non-periodic Perlin noise.

See noise() for shared behavior, restrictions, and a usage example.

Parameters:
  • state – RNG state that selects the noise field (see rand_init()); never advanced.

  • xy – Coordinate to sample. One noise feature spans one unit.

Returns:

The noise value at xy.

warp.noise(state: uint32, xyz: vec3f) float
  • Kernel

  • Python

  • Differentiable

Sample 3D non-periodic Perlin noise.

See noise() 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. One noise feature spans one unit.

Returns:

The noise value at xyz.

warp.noise(state: uint32, xyzt: vec4f) float
  • Kernel

  • Python

  • Differentiable

Sample 4D non-periodic Perlin noise.

The fourth coordinate is commonly used as time to animate a 3D field. See noise() 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. One noise feature spans one unit.

Returns:

The noise value at xyzt.