Skip to main content

Materials

In luma.gl, a Material describes reusable surface state for one shading model or material schema. A MaterialFactory defines that schema and creates compatible Material instances that can be attached to Models or shared across many ModelNodes in a scenegraph.

Materials are scenegraph-adjacent engine resources:

  • Model uses a material when it draws.
  • ModelNode can reference a Model that already has a material attached.
  • Material-owned bindings typically live in bind group 3.

For scenegraph-specific guidance, see the Scenegraph guide. For bind-group ownership, see the Bind Groups guide.

luma.gl owns the material implementations described here. The glTF converter maps authored factors, textures, and extensions onto those shared materials; retained ANARI scenes use the same PBR shader implementation.

Explore the material property reference for parameters, texture bindings, and inline examples.

See glTF material conversion for importer contracts and ANARI materials for retained parameters.

Using PBR materials​

Use createPBRMaterial from @luma.gl/engine/materials to create a material backed by the shared pbrMaterial shader module. Pass it to a compatible Model through its material prop. Models that share the material see the same uniform updates.

import {createPBRMaterial} from '@luma.gl/engine/materials';

const material = createPBRMaterial(device, {
uniforms: {metallicRoughnessValues: [0, 0.4]}
});
material.setProps({pbrMaterial: {metallicRoughnessValues: [0, 0.8]}});

Pass textures through bindings. The helper derives map-enabled uniforms from the supplied bindings and applies explicit uniform values last. The model's shader defines must enable the corresponding samplers. For extension properties, the feature pages list the required defines. The glTF importer configures these when it creates a model.

The material owns its uniform buffers and borrows the textures you bind. To give a model different bindings, call material.clone({bindings: {...}}) and attach the new material. Cloning copies the existing uniform values. Update the matching map-enabled uniform if the clone adds or removes a map. To share a binding schema across separately created materials, pass the same createPBRMaterialFactory(device) result in their factory option.

See the PBR shader module reference for uniform types and defaults.

What Is a Material?​

A material describes how a surface responds to light and how its surface colors are produced. In practice that includes the surface's bidirectional reflectance distribution function (BRDF), material uniform values, and bindings to textures and samplers.

If a change primarily affects BRDF or surface color response, it belongs in material space. If a change primarily affects how primitives are rasterized, expanded, or derived from mesh topology, it is not just a material concern.

This distinction helps keep material APIs focused:

  • Material-like concerns:
    • pbrMaterial
    • lambertMaterial
    • phongMaterial
    • gouraudMaterial
    • unlitMaterial
    • a possible future normalMaterial used for debugging or inspection
  • Not-just-material concerns:
    • wireframe rendering
    • barycentric wireframe overlays
    • line-topology rendering
    • point or sprite expansion
    • geometry-derived outline or edge rendering

Some visual modes combine both layers. For example, wireframe rendering often needs geometry or pipeline support in addition to shader logic, so it is usually better described as a rendering technique than as a traditional material.

Choosing A Stock Material​

The current built-in lighting materials target different tradeoffs:

MaterialSurface ModelRelative CostTypical Use
unlitMaterialPreserves supplied RGBA without lightingNo lighting dependencies or material uniformsRaster imagery, diagrams, UI surfaces, and baked artwork
lambertMaterialDiffuse-only matte shading with no specular highlightsFastest of the lit stock materialsClean visualizations, extruded solids, and scenes where glossy highlights would add noise
phongMaterialSimple specular model with per-fragment lightingFastGeneral-purpose lit surfaces when you want readable highlights without full PBR complexity
gouraudMaterialSimple specular model with per-vertex lightingFaster than phongMaterial, but lower qualityLarge or simple meshes where lower cost matters more than highlight accuracy
pbrMaterialPhysically based material model with textures and richer surface responseMost expensive of the stock materialsAsset rendering, glTF materials, and scenes that need more realistic surface behavior

In practice:

  • choose unlitMaterial when colors must remain independent of lights and the camera
  • choose lambertMaterial when you want a matte result and the cleanest visual output
  • choose phongMaterial when you want simple shiny highlights and solid default quality
  • choose gouraudMaterial when you want a cheaper approximation of Phong-style lighting
  • choose pbrMaterial when the scene or asset needs material textures and more realistic shading

The four lit stock material families also support unlit?: boolean when you want to keep the same material family on a model but skip lighting calculations.

Dedicated unlit shaders​

Add unlitMaterial to a Model's shader modules and call unlitMaterial_getColor(surfaceColor) with RGBA in either WGSL or GLSL. It returns that color unchanged. The application still owns texture sampling, color factors, alpha blending, and output color-space conversion.

Unlike a lit material with {unlit: true}, the dedicated module includes no light uniforms, material bindings, normal calculations, or lighting dependencies. This reduces the shader/resource requirements for surfaces that are always unlit; it does not promise a specific rendering speedup. Application-owned normal attributes and varyings must be removed separately if unused.

Use the existing unlit flag when lighting needs to toggle without changing the shader. Selecting the dedicated module instead requires a matching shader/pipeline variant. Its common Phong/Gouraud evaluation functions support shader migration; include only one material family at a time. Existing PBR and glTF unlit materials continue to use their own flag and texture processing.

See the unlitMaterial reference for shader signatures and the resource contract.

Materials In The Binding Model​

In the current luma.gl convention:

  • group 0 holds model or draw-local engine state
  • group 2 holds scene-shared lighting and IBL state
  • group 3 holds material state

That means a material is the natural owner of per-surface uniform buffers, textures, and samplers that can be reused across many draws, while scene-level state like lighting stays outside the material itself.