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 everypxcells, with one cell per input unit.stateselects the field and is not advanced. Values have the same scale and device-reproducibility behavior asnoise().Periods must be positive; zero invokes undefined behavior. Samples repeat under whole-period shifts when the original and shifted coordinates remain on the same side of zero. A shift that crosses zero may produce a different value, so use non-negative coordinates when the field must repeat seamlessly.
With negative coordinates, the field has one non-smooth boundary per period along each axis. In 1D, the value is continuous across these boundaries, but Warp autodiff reports a one-sided coordinate derivative. In vector overloads, crossing a boundary can instead produce a finite value jump when another coordinate is fractional. Away from these boundaries, the field is differentiable with respect to coordinates. Period arguments receive no Warp autodiff gradient.
- Parameters:
state – RNG state used as a hash seed (see
rand_init()), never advanced.x – Coordinate to sample. One noise feature spans one unit.
px – Period along x, in units. Must be greater than zero.
- Returns:
The noise value at
x. Exactly zero at integer coordinates, with a theoretical range of±0.5.
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([round(v, 3) for v in values.numpy().tolist()])
[0.174, 0.174, 0.174]
- warp.pnoise( ) 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 used as a hash seed (see
rand_init()), never advanced.xy – Coordinate to sample. One noise feature spans one unit.
px – Period along x, in units. Must be greater than zero.
py – Period along y, in units. Must be greater than zero.
- Returns:
The noise value at
xy. Exactly zero when every component is an integer, with a theoretical range of±sqrt(2)/2.
- warp.pnoise( ) 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 used as a hash seed (see
rand_init()), never advanced.xyz – Coordinate to sample. One noise feature spans one unit.
px – Period along x, in units. Must be greater than zero.
py – Period along y, in units. Must be greater than zero.
pz – Period along z, in units. Must be greater than zero.
- Returns:
The noise value at
xyz. Exactly zero when every component is an integer, with a theoretical range of±sqrt(3)/2.
- warp.pnoise( ) 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 used as a hash seed (see
rand_init()), never advanced.xyzt – Coordinate to sample. One noise feature spans one unit.
px – Period along x, in units. Must be greater than zero.
py – Period along y, in units. Must be greater than zero.
pz – Period along z, in units. Must be greater than zero.
pt – Period along the fourth axis, in units. Must be greater than zero.
- Returns:
The noise value at
xyzt. Exactly zero when every component is an integer, with a theoretical range of±1.