warp.pnoise#

warp.pnoise(state: uint32, x: float32, px: int32) float#
  • Kernel

  • Python

  • Differentiable

Sample 1D Perlin noise that repeats with an integer period.

Wraps the noise() lattice every px cells, with one cell per input unit. state selects the field and is not advanced. Values have the same scale and determinism behavior as noise().

Period arguments must be positive. Negative coordinates are currently unsupported. The field is differentiable with respect to coordinates. Period arguments receive no Warp autodiff gradient.

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

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

  • px – Period along x, in units. px must be greater than zero.

Returns:

The noise value at x.

Example

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

# a point, then the same point shifted by one and by two periods
coords = wp.array([0.75, 4.75, 8.75], dtype=float)
values = wp.zeros(len(coords), dtype=float)

wp.launch(sample_periodic_noise, dim=len(coords), inputs=[42, coords], outputs=[values])
print(np.allclose(values.numpy(), values.numpy()[0]))
True
warp.pnoise(
state: uint32,
xy: vec2f,
px: int32,
py: int32,
) float
  • Kernel

  • Python

  • Differentiable

Sample 2D Perlin noise that repeats with an integer period.

See pnoise() 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.

  • px – Period along x, in units. px must be greater than zero.

  • py – Period along y, in units. py must be greater than zero.

Returns:

The noise value at xy.

warp.pnoise(
state: uint32,
xyz: vec3f,
px: int32,
py: int32,
pz: int32,
) float
  • Kernel

  • Python

  • Differentiable

Sample 3D Perlin noise that repeats with an integer period.

See pnoise() 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.

  • px – Period along x, in units. px must be greater than zero.

  • py – Period along y, in units. py must be greater than zero.

  • pz – Period along z, in units. pz must be greater than zero.

Returns:

The noise value at xyz.

warp.pnoise(
state: uint32,
xyzt: vec4f,
px: int32,
py: int32,
pz: int32,
pt: int32,
) float
  • Kernel

  • Python

  • Differentiable

Sample 4D Perlin noise that repeats with an integer period.

The fourth coordinate is commonly used as looping time. See pnoise() 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.

  • px – Period along x, in units. px must be greater than zero.

  • py – Period along y, in units. py must be greater than zero.

  • pz – Period along z, in units. pz must be greater than zero.

  • pt – Period along the fourth axis, in units. pt must be greater than zero.

Returns:

The noise value at xyzt.