API

Interface ShaderMaterial

A custom WGSL material: compiled from user-supplied vertex/fragment sources with declared attributes, uniforms, samplers, external textures, and defines. Update its values via setShaderUniform() / setShaderTexture() and friends.

interface ShaderMaterial {
    attributes: readonly ShaderAttributeName[];
    backFaceCulling: boolean;
    blend?: GPUBlendState;
    blendMode: "additive" | "alpha";
    defines: readonly ShaderDefine[];
    depthBias: number;
    depthBiasSlopeScale: number;
    depthCompare: GPUCompareFunction;
    depthOnlyFragment: boolean;
    depthWrite: boolean;
    fragmentSource: WgslSource;
    metadata?: LiteMetadata;
    name?: string;
    needAlphaBlending: boolean;
    needAlphaTesting: boolean;
    samplerDecls: readonly ShaderSamplerDecl[];
    stencil?: StencilState;
    storageBufferDecls: readonly ShaderStorageBufferDecl[];
    transmissive: boolean;
    uniformDecls: readonly ShaderUniformDecl[];
    vertexSource: WgslSource;
}

Hierarchy (View Summary)

Index
attributes: readonly ShaderAttributeName[]
backFaceCulling: boolean
blend?: GPUBlendState

Explicit blend-state override (see ShaderMaterialOptions.blend).

blendMode: "additive" | "alpha"
defines: readonly ShaderDefine[]
depthBias: number
depthBiasSlopeScale: number
depthCompare: GPUCompareFunction
depthOnlyFragment: boolean
depthWrite: boolean
fragmentSource: WgslSource
metadata?: LiteMetadata

User metadata. glTF loads populate metadata.gltf.extras when source extras exist.

name?: string

Optional human-readable name. Populated by loaders from the source asset (e.g. the glTF material name) so callers can look a material up by name.

needAlphaBlending: boolean
needAlphaTesting: boolean
samplerDecls: readonly ShaderSamplerDecl[]
stencil?: StencilState

Optional stencil-test state baked into the main-pass pipeline (mask write / discard). Set after creation (mat.stencil = { ... }) and call enableMaterialStencil() before registerScene. Default none. See StencilState.

storageBufferDecls: readonly ShaderStorageBufferDecl[]
transmissive: boolean

True for transmissive/refractive surfaces (see ShaderMaterialOptions.transmissive).

uniformDecls: readonly ShaderUniformDecl[]
vertexSource: WgslSource