Clearcoat
Clearcoat adds a secondary glossy layer over a base surface, useful for varnish, lacquer, and automotive paint.
Configuration​
import {Model} from '@luma.gl/engine/api';
import {createPBRMaterial, type PBRMaterial} from '@luma.gl/engine/materials';
const material: PBRMaterial = createPBRMaterial(device, {
uniforms: {
metallicRoughnessValues: [0.5, 0.4],
clearcoatFactor: 1,
clearcoatRoughnessFactor: 0.1
}
});
// modelProps contains your existing shaders, geometry, and buffer layout.
const model = new Model(device, {
...modelProps,
material,
defines: {...modelProps.defines, USE_MATERIAL_EXTENSIONS: true}
});
Parameters​
| Parameter | Default | Description |
|---|---|---|
clearcoatFactor | 0 | Strength of the secondary clearcoat layer, in the range 0–1. |
clearcoatRoughnessFactor | 0 | Roughness of the clearcoat layer, in the range 0–1. |
clearcoatMapEnabled | false | Enables clearcoat-strength texture sampling. |
clearcoatRoughnessMapEnabled | false | Enables clearcoat-roughness texture sampling. |
Texture bindings​
| Field | Model define | Description |
|---|---|---|
pbr_clearcoatSampler | HAS_CLEARCOATMAP: true | Texture resource for the clearcoat slot. |
pbr_clearcoatRoughnessSampler | HAS_CLEARCOATROUGHNESSMAP: true | Texture resource for the clearcoatRoughness slot. |
pbr_clearcoatNormalSampler | HAS_CLEARCOATNORMALMAP: true | Texture resource for the clearcoatNormal slot. |
Enable USE_MATERIAL_EXTENSIONS on custom models. The glTF importer enables it automatically.
See Using PBR materials for material setup.
Remarks​
KHR_materials_clearcoatsupplies clearcoat strength, roughness, and an optional normal map for the coating.