Volume absorption
Volume thickness and absorption tint transmitted light according to the distance it travels through a material.
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, 0.05],
transmissionFactor: 1,
thicknessFactor: 0.5,
attenuationColor: [0.8, 0.95, 1],
attenuationDistance: 2
}
});
// modelProps contains your shaders, geometry, and buffer layout.
const model = new Model(device, {
...modelProps,
material,
defines: {...modelProps.defines, USE_MATERIAL_EXTENSIONS: true}
});
See transmission for the scene-color capture used by this viewer.
Parameters​
| Parameter | Default | Description |
|---|---|---|
transmissionFactor | 0 | Fraction of light transmitted through the surface. |
thicknessFactor | 0 | Volume thickness in model-space units; 0 describes a thin surface. |
attenuationColor | [1, 1, 1] | Color transmitted after the attenuation distance. |
attenuationDistance | 1e9 | Distance associated with attenuationColor; the large default approximates no absorption. |
Texture bindings​
| Binding | Model define | Description |
|---|---|---|
pbr_thicknessSampler | HAS_THICKNESSMAP: true | Linear green-channel multiplier for thicknessFactor. |
Enable USE_MATERIAL_EXTENSIONS on custom models. The glTF importer enables it automatically.
See Using PBR materials for material setup.
Remarks​
KHR_materials_volumesupplies thickness, a thickness texture (green channel), attenuation color, and attenuation distance. The importer represents infinite attenuation distance as1e9.