AbstractAbstract ReadonlyshaderStable per-subclass identifier. All instances with the same shaderId
MUST produce identical getShaderCode output and identical
getBindGroupLayout layouts on a given device — the pass uses this
as the pipeline cache key.
OptionalnameOptional human-readable name (e.g. the source glTF material name). Display only — the editor surfaces it in the Inspector; the renderer never keys on it.
True for alpha-blended materials. ForwardPass routes these through its transparent sub-pass (after opaque) with depth-write disabled.
Face-culling mode used when a pass builds this material's render pipeline:
'back' (default) culls back faces, 'front' culls front faces, 'none'
draws both sides. A per-draw doubleSided flag (e.g. mixed-winding tile
content) forces 'none' regardless of this setting. Passes fold this into
their pipeline cache key, so it may differ between instances sharing a
shaderId.
Constant polygon depth-bias applied when a pass builds this material's render
pipeline. A positive value nudges this material's fragments toward the
camera (the pass multiplies it by RenderContext.depthBiasSign so the
sign is correct under standard- or reversed-Z), so coincident geometry drawn on
top of other surfaces — draped vector overlays / decals sitting exactly on
terrain — wins the depth test instead of Z-fighting. 0 (default) adds no bias.
Units follow WebGPU depthBias (depth-buffer units; for a float depth target the
effective offset scales with the fragment's exponent, so depthBiasSlopeScale
is usually the more robust knob). Passes fold it into their pipeline cache key, so
it may differ between instances sharing a shaderId.
Slope-scaled companion to depthBias (WebGPU depthBiasSlopeScale):
bias proportional to the polygon's depth slope, so steeply-angled draped
geometry gets more offset where it needs it (grazing angles) and less where it
doesn't. Same toward-the-camera sign convention as depthBias. 0
(default) = no slope bias. Also part of the pipeline cache key.
AbstractgetReturns the WGSL source for a given pass type and variant mask.
Which pass is asking.
OptionalvariantMask: numberBitmask selecting shader variant (interpretation is material-specific).
WGSL source.
AbstractgetReturns the bind group layout for slot MATERIAL_GROUP. Implementations
MUST cache the layout per device — typically with a static WeakMap<GPUDevice, ...>.
OptionalvariantMask: numberBitmask of variant flags to select which bindings are included.
AbstractgetReturns the bind group instance for slot MATERIAL_GROUP. Implementations
may cache the bind group internally and recreate it lazily when textures or
other resource references change.
OptionalupdateOptional: called by the pass once per draw before binding, so the material can flush any dirty CPU-side parameter changes into its uniform buffers.
OptionaldestroyOptional: release any GPU resources owned by this material instance (uniform buffers, owned textures). Bind group layouts shared across instances should NOT be destroyed here.
Abstract base for shader+data bundles consumed by the geometry, forward, and skinned-geometry passes.
Subclasses provide WGSL plus a
MATERIAL_GROUPbind group containing their uniforms, textures, and samplers. Passes cache pipelines keyed by shaderId, so all instances sharing ashaderIdmust produce the same shader code, the same bind group layout, and the same vertex expectations as each other.