Skip to content

material.data#getColormapForBinding

Summary

material.data#getColormapForBinding returns the assigned Colormap instance or resolves a built-in name to its shared singleton. The returned resource is not owned by the material.

Syntax

DataMaterial.getColormapForBinding(): Colormap
const result = material.getColormapForBinding();

Returns

Colormap - Assigned instance unchanged, or the singleton resolved from the assigned built-in name.

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const material = wgpu.material.data({ data: new Float32Array([0.2, 0.4, 0.7, 1.0]), scaleTransform: { mode: "linear", domainMin: 0, domainMax: 1 }, colormap: "viridis" });
const colormap = material.getColormapForBinding();
console.log(colormap === wgpu.colormap.viridis()); // true

See Also