Taos API Reference
    Preparing search index...

    Interface MaterialAbstract

    Abstract base for shader+data bundles consumed by the geometry, forward, and skinned-geometry passes.

    Subclasses provide WGSL plus a MATERIAL_GROUP bind group containing their uniforms, textures, and samplers. Passes cache pipelines keyed by shaderId, so all instances sharing a shaderId must produce the same shader code, the same bind group layout, and the same vertex expectations as each other.

    interface Material {
        shaderId: string;
        transparent: boolean;
        cullMode: GPUCullMode;
        getShaderCode(passType: MaterialPassType, variantMask?: number): string;
        getBindGroupLayout(
            device: GPUDevice,
            variantMask?: number,
        ): GPUBindGroupLayout;
        getBindGroup(device: GPUDevice): GPUBindGroup;
        update?(queue: GPUQueue): void;
        destroy?(): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    shaderId: string

    Stable 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.

    transparent: boolean = false

    True for alpha-blended materials. ForwardPass routes these through its transparent sub-pass (after opaque) with depth-write disabled.

    cullMode: GPUCullMode = 'back'

    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.

    Methods

    • Returns the WGSL source for a given pass type and variant mask.

      Parameters

      • passType: MaterialPassType

        Which pass is asking.

      • OptionalvariantMask: number

        Bitmask selecting shader variant (interpretation is material-specific).

      Returns string

      WGSL source.

      If the material does not support passType.

    • Returns the bind group layout for slot MATERIAL_GROUP. Implementations MUST cache the layout per device — typically with a static WeakMap<GPUDevice, ...>.

      Parameters

      • device: GPUDevice
      • OptionalvariantMask: number

        Bitmask of variant flags to select which bindings are included.

      Returns GPUBindGroupLayout

    • Optional: called by the pass once per draw before binding, so the material can flush any dirty CPU-side parameter changes into its uniform buffers.

      Parameters

      Returns void

    • Optional: release any GPU resources owned by this material instance (uniform buffers, owned textures). Bind group layouts shared across instances should NOT be destroyed here.

      Returns void