warp.Texture2D#
- class warp.Texture2D(*args, **kwargs)[source]#
2D texture class.
This is a specialized version of
Texturewith dimensionality fixed to 2. Use this for explicit 2D texture creation and as a type hint in kernel parameters.Example:
import warp as wp import numpy as np data = np.random.rand(256, 256, 4).astype(np.float32) tex = wp.Texture2D(data, device="cuda:0") @wp.kernel def sample_kernel(tex: wp.Texture2D, output: wp.array(dtype=float)): tid = wp.tid() output[tid] = wp.texture_sample(tex, wp.vec2f(0.5, 0.5), dtype=float)
- Parameters:
- __init__(
- data=None,
- width=0,
- height=0,
- num_channels=4,
- dtype=np.float32,
- filter_mode=1,
- address_mode=None,
- address_mode_u=None,
- address_mode_v=None,
- normalized_coords=True,
- device=None,
Methods
__init__([data, width, height, ...])Attributes
ADDRESS_BORDERADDRESS_CLAMPADDRESS_MIRRORADDRESS_WRAPFILTER_LINEARFILTER_POINTaddress_mode_uAddress mode for U axis.
address_mode_vAddress mode for V axis.
address_mode_wAddress mode for W axis (3D only).
depthTexture depth in pixels (1 for 2D textures).
dimsTexture dimensionality (2 or 3).
dtypeData type of the texture.
heightTexture height in pixels.
idTexture handle ID (for advanced use).
normalized_coordsWhether texture uses normalized coordinates.
num_channelsNumber of channels.
widthTexture width in pixels.