@pixi/3d
    Preparing search index...

    Interface Material3DOptions

    Options for Material3D

    Each extension (emissive, specular, iridescence, transmission, clearcoat, sheen, anisotropy) is a group that turns the feature on when passed, even empty: clearcoat: {} adds a full-strength coat. Inside a group, each factor and strength defaults to 1 and each colour to white; the glTF loader passes each extension's own defaults instead.

    const options: Material3DOptions = { baseColor: 0x8c1c13, roughness: 0.4, clearcoat: {} };
    const carPaint = new Material3D(options);
    interface Material3DOptions {
        alpha?: number;
        alphaCutoff?: number;
        alphaMode?: AlphaMode;
        anisotropy?: AnisotropyOptions;
        baseColor?: ColorSource;
        baseColorTexture?: Texture<TextureSource<any>>;
        clearcoat?: ClearcoatOptions;
        doubleSided?: boolean;
        emissive?: EmissiveOptions;
        extraBits?: readonly ShaderBit[];
        flatShading?: boolean;
        fog?: boolean;
        ior?: number;
        iridescence?: IridescenceOptions;
        label?: string;
        metallic?: number;
        metallicRoughnessTexture?: Texture<TextureSource<any>>;
        normalScale?: number;
        normalTexture?: Texture<TextureSource<any>>;
        occlusionStrength?: number;
        occlusionTexture?: Texture<TextureSource<any>>;
        passes?: Record<string, boolean | PassDescriptorOptions>;
        roughness?: number;
        sheen?: SheenOptions;
        specular?: SpecularOptions;
        textures?: Record<string, Texture<TextureSource<any>> | undefined>;
        topology?: Topology;
        transmission?: TransmissionOptions;
        uvTransform?: Matrix;
        vertexColors?: boolean;
    }

    Hierarchy

    Index
    alpha?: number

    Base opacity; alphaMode: 'opaque' ignores it

    1
    
    new Material3D({ alphaMode: 'blend', alpha: 0.4 });
    
    alphaCutoff?: number

    Alpha below which fragments are discarded when alphaMode is 'mask'

    0.5
    
    new Material3D({ baseColorTexture: leafTexture, alphaMode: 'mask', alphaCutoff: 0.3 });
    
    alphaMode?: AlphaMode

    How alpha is treated; see AlphaMode

    'opaque'
    
    new Material3D({ baseColorTexture: leafTexture, alphaMode: 'mask' });
    
    anisotropy?: AnisotropyOptions

    Highlights stretched along one direction; passing the group turns it on

    const pan = new Material3D({ metallic: 1, anisotropy: {} });
    
    baseColor?: ColorSource

    Base colour tint; the source's alpha is ignored, BaseMaterial3DOptions#alpha sets opacity

    new Material3D({ baseColor: 0xff7733 });
    
    baseColorTexture?: Texture<TextureSource<any>>

    Base colour (albedo) texture

    Texture.WHITE
    
    new Material3D({ baseColorTexture: crateTexture });
    
    clearcoat?: ClearcoatOptions

    Clear lacquer layer on top; passing the group turns it on

    const pianoBlack = new Material3D({ baseColor: 0x050505, clearcoat: {} });
    
    doubleSided?: boolean

    When true, back faces are drawn too and lit with their normal flipped

    Fixed at construction.

    false
    
    new Material3D({ baseColorTexture: leafTexture, alphaMode: 'mask', doubleSided: true });
    
    emissive?: EmissiveOptions

    The material's own glow; passing the group turns it on

    const lava = new Material3D({ emissive: { texture: lavaGlow, strength: 4 } });
    
    extraBits?: readonly ShaderBit[]

    Extra shader bits composed into the material's shader, fixed for its lifetime

    Material3D, PhongMaterial and FlatMaterial each document where they sit in their bit list; on a material built from a raw descriptor, as ToonMaterial and PortalMaterial are, they follow its bits. A bit may declare material fields and textures; fill its textures through the textures option, or later through BaseMaterial3D#textures. A bit that uses PI or INV_PI lists mathConstantsBit in its ShaderBit#requires rather than declaring them, and one that calls screenUVFromWorld or sampleScreenCopy lists screenSpaceFuncsBit. To add bits to a material that exists, such as one the glTF loader built, material.clone({ extraBits }) makes a copy with them and everything else the material has. For billboarding, set Mesh3D#billboardMode instead.

    new Material3D({ baseColor: 0xff3355, extraBits: [glossBit] });
    
    flatShading?: boolean

    When true, each triangle is shaded with its face normal instead of the smooth vertex normal

    Gives a faceted, low-poly look with no duplicated vertices, so one geometry can draw smooth or faceted depending on its material. A normal map still applies on top. No visible effect on an unlit material such as FlatMaterial. Fixed at construction.

    false
    
    new Material3D({ baseColor: 0x8a7f72, flatShading: true });
    
    fog?: boolean

    Whether the view's distance fog may reach this material

    Turn it off for skyboxes, water and anything else with its own distance falloff; a sky dome past the fog's far distance would turn flat fog colour. Fixed at construction.

    true
    
    new Material3D({ baseColorTexture: skyTexture, fog: false });
    
    ior?: number

    Index of refraction, see Material3D#ior

    1.5
    
    const water = new Material3D({ ior: 1.33, transmission: { thickness: 1 } });
    
    iridescence?: IridescenceOptions

    Thin-film colour shift; passing the group turns it on

    const soapBubble = new Material3D({ iridescence: {}, transmission: {} });
    
    label?: string

    Name for debugging and for finding the material; the glTF loader sets it to the name in the file

    new Material3D({ label: 'Paint' });
    
    metallic?: number

    Metalness, from 0 (non-metal) to 1 (metal)

    0
    
    const gold = new Material3D({ baseColor: 0xffc356, metallic: 1, roughness: 0.25 });
    
    metallicRoughnessTexture?: Texture<TextureSource<any>>

    Map with roughness in green and metalness in blue, as in glTF; scales roughness and metallic

    const rusty = new Material3D({ metallic: 1, metallicRoughnessTexture: rustMap });
    
    normalScale?: number

    Strength of the normal map's bumps

    1
    
    const shallow = new Material3D({ normalTexture: brickNormals, normalScale: 0.5 });
    
    normalTexture?: Texture<TextureSource<any>>

    Tangent-space normal map, green up as in glTF and OpenGL

    Invert the green channel of a DirectX-style map, or its bumps light from the wrong side. Needs UVs on the geometry, and uses its tangents when it has them. Can be assigned later through material.textures.normal; a material without one pays nothing for normal mapping.

    const bricks = new Material3D({ baseColorTexture: brickColour, normalTexture: brickNormals });
    
    occlusionStrength?: number

    Multiplier on the occlusion, see Material3D#occlusionStrength

    1
    
    const softer = new Material3D({ occlusionTexture: crateOcclusion, occlusionStrength: 0.8 });
    
    occlusionTexture?: Texture<TextureSource<any>>

    Ambient occlusion map, read from red; it darkens ambient and environment light only

    const crate = new Material3D({ baseColorTexture: crateColour, occlusionTexture: crateOcclusion });
    
    passes?: Record<string, boolean | PassDescriptorOptions>

    Extra render passes this material draws in, keyed by the pass's name

    • true: draw in the pass with the pass's own shader and state.
    • a PassDescriptorOptions object: draw in it with your own shader, state or topology. PassDescriptor says how these combine with the pass's own; they can't change later.
    • false, or left out: don't draw in it. Useful for opting out of a pass that spread options or a subclass default turned on.

    A material can name a pass before the pass exists. A page has room for 24 custom pass names, 'outline' included, each taken the first time anything names it; a name past that joins nothing, and a pass with it draws no meshes, without a warning.

    view.passes = [new OutlinePass({ width: 0.05 })];
    const hero = new Material3D({ baseColor: 0xff7733, passes: { outline: true } });
    roughness?: number

    Perceptual roughness, from 0 (mirror-like) to 1 (fully rough)

    1
    
    const polished = new Material3D({ roughness: 0.1 });
    
    sheen?: SheenOptions

    Cloth sheen; passing the group turns it on

    const cushion = new Material3D({ sheen: { color: 0xffffff, roughness: 0.5 } });
    
    specular?: SpecularOptions

    Strength and tint of non-metal reflections; passing the group turns it on

    const lacquer = new Material3D({ specular: { color: 0xfff4e0 } });
    
    textures?: Record<string, Texture<TextureSource<any>> | undefined>

    Textures by slot name, for the slots a descriptor or extraBits declares

    The bits' textures arrays decide which slots exist; this map only fills them. A slot left out gets Texture.WHITE. A baseColor entry here wins over BaseMaterial3DOptions#baseColorTexture.

    new BaseMaterial3D({
    descriptor: { bitsGpu: [waterBit], bitsGl: [waterBit] },
    textures: { waterNormal: waterNormalTexture },
    });
    topology?: Topology

    Primitive topology for every pass that doesn't set its own; left out, the geometry's is used

    'line-list' joins the indices in pairs, so a triangle index buffer drawn that way isn't a wireframe: it draws some edges and misses others. Use a geometry with line indices for that.

    new FlatMaterial({ baseColor: 0x00ff00, topology: 'point-list' });
    
    transmission?: TransmissionOptions

    Glass and other see-through surfaces; passing the group turns it on

    const pane = new Material3D({ roughness: 0, transmission: {} });
    
    uvTransform?: Matrix

    UV transform for every texture of the material; see BaseMaterial3D#uvTransform

    Leave it out to let a framed (spritesheet) base colour texture set the transform.

    new Material3D({ baseColorTexture: tileTexture, uvTransform: new Matrix().scale(4, 4) });
    
    vertexColors?: boolean

    Whether a geometry's vertex colours (its colors) tint this material; see BaseMaterial3D#vertexColors

    false
    
    new Material3D({ vertexColors: true });