Texture definitions establish allocation, sampling, upload, and shader-visibility contracts. Runtime values provide or replace source images without changing that declaration.
Definition
Each fragment-visible texture uImage produces uImage and uImageSampler bindings. A null runtime source uses a valid fallback texture.
Runtime values
source and state.setTexture(...) accept ImageBitmap, image, canvas, video, { source, width?, height?, colorSpace?, flipY?, premultipliedAlpha?, generateMipmaps?, update? }, or null.
Update mode precedence is runtime override, definition default, then automatic fallback:
Video sources default to perFrame; other sources default to once.
Sampling constraints
Integer *uint and *sint storage formats default to fragmentVisible: false, because fragment bindings use texture_2d<f32>. Explicitly enabling fragment visibility for one of those formats throws.
r32float, rg32float, and rgba32float use non-filtering sampling unless the device supports float32-filterable. When unsupported, a requested linear filter is coerced to nearest to keep bind-group and sampler types valid.
Storage textures
storage: true requires an explicit storage-compatible format, width, and height, and rejects source. Compute bindings are generated independently of fragmentVisible.
Use PingPongComputePass with a storage texture. A PingPongShaderPass target must instead be a normal fragment-visible sampled texture; the feedback pass owns its A/B render textures.
Allocation and mipmaps
The renderer reallocates when source dimensions or allocation format change and otherwise follows the update mode. Mipmaps are generated by rendering each level from the previous level in the same GPU allocation.
See Texture Loading for URL loading, Compute Shaders for storage bindings, and the Glass Pane demo for an editable loaded texture.