DriftTexture · interface
MaterialArray
Materials as slices of a few texture arrays, which is what WebGPU can bind.
Explained in DriftTexture.
interface MaterialArrayimport type { MaterialArray } from '@driftengine/texture';In depth
This is the binding design, and it is why this package lands in the same wave as the GPU-driven pipeline rather than later. WebGPU has no bindless resource access, which is the usual way a GPU-driven renderer reaches a thousand materials from one indirect draw. A thousand materials as six thousand independent textures is unreachable. A thousand materials as a thousand latent slices in a handful of arrays, indexed by a material identifier read from a storage buffer, is ordinary.
Identical content shares a layer. The tile index already hashes by content, so two materials whose latents are the same occupy one layer — which is the deduplication paying for itself a second time, in binding slots rather than in bytes.
Properties
| Name | Type | Description |
|---|---|---|
layerOf | Map<number, number> | Layer per material identifier. |
layerByHash | Map<string, number> | Which content hash each layer holds, so identical latents share one. |
layerCapacity | number | |
tileSize | number | |
used | number |