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 determinism behavior asnoise().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.
pxmust 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( ) 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.
pxmust be greater than zero.py – Period along y, in units.
pymust be greater than zero.
- Returns:
The noise value at
xy.
- 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 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.
pxmust be greater than zero.py – Period along y, in units.
pymust be greater than zero.pz – Period along z, in units.
pzmust be greater than zero.
- Returns:
The noise value at
xyz.
- 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 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.
pxmust be greater than zero.py – Period along y, in units.
pymust be greater than zero.pz – Period along z, in units.
pzmust be greater than zero.pt – Period along the fourth axis, in units.
ptmust be greater than zero.
- Returns:
The noise value at
xyzt.