API

Interface PbrMaterialProps

User-facing properties for a physically based (metallic-roughness) material. Create one manually via createPbrMaterial() or let loadGltf() build it. Optional sub-feature objects (clearcoat, sheen, anisotropy, subsurface) are only bundled when referenced.

interface PbrMaterialProps {
    alpha?: number;
    alphaBlend?: boolean;
    baseColorFactor?: [number, number, number, number];
    baseColorTexture?: Texture2D;
    directIntensity?: number;
    doubleSided?: boolean;
    emissiveTexture?: Texture2D;
    enableSpecularAA?: boolean;
    environmentIntensity?: number;
    gammaLightmap?: boolean;
    lightmapCoordIndex?: 0 | 1;
    lightmapLevel?: number;
    lightmapTexture?: Texture2D;
    metadata?: LiteMetadata;
    metallicFactor?: number;
    name?: string;
    normalTexture?: Texture2D;
    normalTextureScale?: number;
    occlusionStrength?: number;
    occlusionTexCoord?: number;
    occlusionTexture?: Texture2D;
    ormTexture?: Texture2D;
    plugins?: MaterialPlugin[];
    reflectance?: number;
    roughnessFactor?: number;
    specGlossTexture?: Texture2D;
    stencil?: StencilState;
    useLightmapAsShadowmap?: boolean;
    usePhysicalLightFalloff?: boolean;
}

Hierarchy (View Summary)

Index
alpha?: number

Overall material alpha (0=fully transparent, 1=opaque). Default 1.0.

alphaBlend?: boolean

Enable alpha blending (glTF alphaMode "BLEND"). Enables radianceOverAlpha + specularOverAlpha.

baseColorFactor?: [number, number, number, number]

Linear RGB/A factor multiplied with the base-color texture (glTF baseColorFactor). Default [1,1,1,1].

baseColorTexture?: Texture2D
directIntensity?: number

Scale factor for direct light contribution. Default 1.0.

doubleSided?: boolean

Whether material is double-sided (disables back-face culling).

emissiveTexture?: Texture2D
enableSpecularAA?: boolean

Enable specular anti-aliasing on IBL alphaG (matches BJS SPECULARAA). Default false. Set automatically by the glTF loader for materials loaded from glTF files.

environmentIntensity?: number

Scale factor for environment/IBL contribution. Default 1.0.

gammaLightmap?: boolean

Decode the sampled lightmap from sRGB to linear before composition. Default false.

lightmapCoordIndex?: 0 | 1

UV set sampled by the lightmap: 0 = TEXCOORD_0, 1 = TEXCOORD_1. Default 1.

lightmapLevel?: number

Lightmap intensity multiplier (Babylon.js lightmapTexture.level). Default 1.0.

lightmapTexture?: Texture2D

Baked lightmap texture. Added to the shaded color by default, or multiplied when useLightmapAsShadowmap is true. Set via setPbrLightmap.

metadata?: LiteMetadata

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

metallicFactor?: number

glTF metallicFactor multiplier applied over ORM.b metallic channel. Default 1.0.

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.

normalTexture?: Texture2D
normalTextureScale?: number

Normal map scale (glTF normalTexture.scale). Default 1.0.

occlusionStrength?: number

Strength of ambient occlusion from ORM R channel. Default 1.0; 0.0 ignores R channel.

occlusionTexCoord?: number

glTF-derived UV set index for the occlusion texture: 0 = first UV set (TEXCOORD_0), 1 = second UV set (TEXCOORD_1). Default 0. Populated only by the glTF loader paths (gltf-pbr-builder-ext and KHR_texture_basisu). It selects WHICH UV set occlusion samples; whether UV2 gets plumbed at all is gated by _uv2Mask (occlusion contributes bit 32), which the slow path computes from this same value — so every occlusion-on-UV1 glTF material also carries _uv2Mask. Setting this alone (without _uv2Mask) does not force UV2 plumbing.

occlusionTexture?: Texture2D

Separate occlusion texture sampled with UV2 when occlusionTexCoord=1. R channel is occlusion. When set, ORM.r is NOT used for occlusion.

ormTexture?: Texture2D

Occlusion-Roughness-Metallic packed: R=occ, G=rough, B=metal.

plugins?: MaterialPlugin[]

Optional opt-in material plugins (custom WGSL + uniforms + samplers layered on top of the built-in PBR pipeline). Attach via material.plugins = [plugin], then call enableMaterialPlugins(scene) before registerScene.

reflectance?: number

Dielectric F0 reflectance (default 0.04, glass ≈ 0.2).

roughnessFactor?: number

glTF roughnessFactor multiplier applied over ORM.g roughness channel. Default 1.0.

specGlossTexture?: Texture2D

KHR_materials_pbrSpecularGlossiness: RGB=specular, A=glossiness.

stencil?: StencilState

Optional stencil-test state baked into the main-pass pipeline. Lets this material write the stencil buffer where it draws (mask) or discard where another material wrote it. Default none. See StencilState.

useLightmapAsShadowmap?: boolean

Multiply the shaded color by the lightmap instead of adding it. Default false.

usePhysicalLightFalloff?: boolean

Whether direct point/spot lights use physical inverse-square falloff. Default true, matching Babylon.js PBRMaterial. Set false for Standard-style linear range + spot exponent falloff (usePhysicalLightFalloff = false).