warp.volume_lookup#
- warp.volume_lookup( ) Any#
Kernel
Return the value of type
dtypestored at the voxel with integer index-space coordinatesi,j,k, without interpolation.The lookup follows NanoVDB value resolution: inactive leaf voxels and internal tiles may carry stored inactive values that differ from the grid’s root background value. A location with no more specific stored value resolves to the background. The result is
0if the volume does not store values of typedtype. Not differentiable; usevolume_sample()for interpolated reads of floating-point scalar and vector data.- Parameters:
id – The
idof awarp.Volume.i – Voxel coordinate along the first index-space axis (may be negative).
j – Voxel coordinate along the second index-space axis (may be negative).
k – Voxel coordinate along the third index-space axis (may be negative).
dtype – Value type stored by the volume (see
volume_sample()).
- Returns:
The resolved voxel value of type
dtype.
Example
@wp.kernel def lookup(vid: wp.uint64, out: wp.array[wp.float32]): out[0] = wp.volume_lookup(vid, 1, 0, 0, dtype=float) values = np.zeros((2, 2, 2), dtype=np.float32) values[1, :, :] = 1.0 # f(i, j, k) = i volume = wp.Volume.load_from_numpy(values, voxel_size=1.0, bg_value=0.0) out = wp.zeros(1, dtype=wp.float32) wp.launch(lookup, dim=1, inputs=[volume.id], outputs=[out]) print(round(float(out.numpy()[0]), 1))
1.0