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. Each coordinate dimensionality defines a distinct field.

Values are centered on zero, are exactly zero at integer lattice points, and have a theoretical range of ±sqrt(N)/2 for N dimensions. Differentiable with respect to the coordinate. Results are reproducible per device, but CPU and CUDA values may differ slightly. Use pnoise() for periodic noise.

Keep each coordinate component below 2^23 (about 8.4e6). At that magnitude and above, float32 cannot represent sub-cell coordinates: scalar noise returns zero, while vector noise may remain nonzero if another component is fractional. Coordinates outside the signed 32-bit lattice-index range are unsupported.

Parameters:
  • state – RNG state used as a hash seed (see rand_init()), never advanced.

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

Returns:

The noise value at x. Exactly zero at integer coordinates, with a theoretical range of ±0.5.

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])
print([round(v, 3) for v in values.numpy().tolist()])
[0.243, -0.09, -0.11]
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 used as a hash seed (see rand_init()), never advanced.

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

Returns:

The noise value at xy. Exactly zero when every component is an integer, with a theoretical range of ±sqrt(2)/2.

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 used as a hash seed (see rand_init()), never advanced.

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

Returns:

The noise value at xyz. Exactly zero when every component is an integer, with a theoretical range of ±sqrt(3)/2.

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 used as a hash seed (see rand_init()), never advanced.

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

Returns:

The noise value at xyzt. Exactly zero when every component is an integer, with a theoretical range of ±1.