Skip to main content

Volume absorption

Volume thickness and absorption tint transmitted light according to the distance it travels through a material.

GitHub
0.0s
Compare the background through the thin and thick materials. A longer path through the volume absorbs more light.

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​

ParameterDefaultDescription
transmissionFactor0Fraction of light transmitted through the surface.
thicknessFactor0Volume thickness in model-space units; 0 describes a thin surface.
attenuationColor[1, 1, 1]Color transmitted after the attenuation distance.
attenuationDistance1e9Distance associated with attenuationColor; the large default approximates no absorption.

Texture bindings​

BindingModel defineDescription
pbr_thicknessSamplerHAS_THICKNESSMAP: trueLinear 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_volume supplies thickness, a thickness texture (green channel), attenuation color, and attenuation distance. The importer represents infinite attenuation distance as 1e9.