Nano WebGPU API - v0.11.0
    Preparing search index...

    Class StandardMaterial

    StandardMaterial represents a Physically-Based Rendering (PBR) metallic-roughness material. Manages material parameter uniform structures, linear samplers, lazy-loading sequences for texture assets, handles shadow filtering variant compilation keys, and supports double-sided material rendering.

    Hierarchy (View Summary)

    Index

    Accessors

    • get aoIntensity(): number

      Gets the ambient occlusion shadow intensity multiplier.

      Returns number

    • set aoIntensity(val: number): void

      Sets the ambient occlusion shadow intensity multiplier and marks the material parameters as dirty.

      Parameters

      • val: number

      Returns void

    • get depthCompare(): GPUCompareFunction

      Gets the depth check comparison function.

      Returns GPUCompareFunction

    • set depthCompare(value: GPUCompareFunction): void

      Sets the depth check comparison function.

      Parameters

      • value: GPUCompareFunction

      Returns void

    • get depthWriteEnabled(): boolean

      Gets whether depth buffer updates are enabled.

      Returns boolean

    • set depthWriteEnabled(value: boolean): void

      Sets whether depth buffer updates are enabled.

      Parameters

      • value: boolean

      Returns void

    • get doubleSided(): boolean

      Gets the double-sided rendering state.

      Returns boolean

    • set doubleSided(val: boolean): void

      Sets the double-sided rendering state, adjusting internal cull modes accordingly.

      Parameters

      • val: boolean

      Returns void

    • get emissiveStrength(): number

      Gets the emissive intensity multiplier.

      Returns number

    • set emissiveStrength(val: number): void

      Sets the emissive intensity multiplier and marks the material parameters as dirty.

      Parameters

      • val: number

      Returns void

    • get metallic(): number

      Gets the microfacet metallic factor.

      Returns number

    • set metallic(val: number): void

      Sets the microfacet metallic factor and marks the material parameters as dirty.

      Parameters

      • val: number

      Returns void

    • get normalScale(): number

      Gets the normal tangent scale.

      Returns number

    • set normalScale(val: number): void

      Sets the normal tangent scale and marks the material parameters as dirty.

      Parameters

      • val: number

      Returns void

    • get opacity(): number

      Gets the opacity component of the albedo color.

      Returns number

    • set opacity(value: number): void

      Sets the opacity component of the albedo color, automatically enabling transparent rendering and disabling depth writing if opacity is less than 1.0.

      Parameters

      • value: number

      Returns void

    • get roughness(): number

      Gets the microfacet roughness factor.

      Returns number

    • set roughness(val: number): void

      Sets the microfacet roughness factor and marks the material parameters as dirty.

      Parameters

      • val: number

      Returns void

    • get transparent(): boolean

      Gets whether transparency blending is enabled.

      Returns boolean

    • set transparent(value: boolean): void

      Sets whether transparency blending is enabled. Automatically sets depthWriteEnabled to false if transparent is true.

      Parameters

      • value: boolean

      Returns void

    Constructors

    Methods

    • Allocates uniform buffers and packages textures, generating a standard bind group (index 2). Triggers asynchronous load sequences for string texture paths. Reuses dummy white/normal maps if optional texture arguments are omitted.

      Parameters

      • ctx: Context

        Active context.

      • Optional_topology: GPUPrimitiveTopology

        Geometry topology.

      • Optional_indexFormat: GPUIndexFormat

        Geometry index format.

      Returns GPUBindGroup

      Standard bind group 2 instance.

    • Custom parameter bind group (group index 3) utilized by custom ShaderMaterials. Returns null by default for StandardMaterial.

      Parameters

      Returns GPUBindGroup | null

      The resolved custom parameters bind group or null.

    • Retrieves or compiles standard PBR pipelines matching specific primitive topology layouts.

      Parameters

      • ctx: Context

        Active context.

      • topology: GPUPrimitiveTopology = "triangle-list"

        Target geometry topology.

      • indexFormat: GPUIndexFormat = "uint16"

        Target index format.

      • OptionalcullMode: GPUCullMode

        Culling mode parameter.

      • useCSM: boolean = false

      Returns GPURenderPipeline

      Compiled render pipeline instance.

    Properties

    id: number

    Unique material identification key.

    isDirty: boolean = true

    Flag indicating if parameter properties are dirty, requiring a new bind group build.

    nextPass: Material | null = null

    Secondary material rendered on top of the current pass. Assign a ShaderMaterial here to layer a second render pass (e.g., outline effect) over the primary material. The next pass automatically uses the same geometry and instance matrices, drawn immediately after.

    type: string = "Material"

    Material class type string tag used for fast runtime polymorphism checks.

    UNIFORM_OFFSETS: {
        ALBEDO_A: 3;
        ALBEDO_B: 2;
        ALBEDO_G: 1;
        ALBEDO_R: 0;
        AO_INTENSITY: 7;
        CULL_MODE: 13;
        EMISSIVE_B: 18;
        EMISSIVE_G: 17;
        EMISSIVE_R: 16;
        EMISSIVE_STRENGTH: 14;
        HAS_AO_MAP: 11;
        HAS_EMISSIVE_MAP: 19;
        HAS_METALLIC_MAP: 10;
        HAS_NORMAL_MAP: 8;
        HAS_ORM_MAP: 12;
        HAS_ROUGHNESS_MAP: 9;
        METALLIC: 5;
        NORMAL_SCALE: 6;
        ROUGHNESS: 4;
    } = ...

    Mappings of PBR parameters to Float32Array offsets matching the WGSL MaterialUniform struct layout.