Bump mapping
A bump map stores surface heights. Shaders use differences between neighboring heights to change how light falls on surfaces. Bump maps are typically used to increase 3D detail in a scene without adding excessively detailed geometry.
Configuration​
Bind a bump map when creating the material. This example takes single-channel height data in a Uint8Array and geometry with normals and UV coordinates.
import {createPBRModel} from '@luma.gl/engine/lighting';
import {createPBRMaterial} from '@luma.gl/engine/materials';
const bumpTexture = device.createTexture({
width,
height,
format: 'r8unorm',
data: heightPixels
});
const material = createPBRMaterial(device, {
bindings: {pbr_bumpSampler: bumpTexture},
uniforms: {bumpFactor: 0.8}
});
const model = createPBRModel(device, {geometry, material});
Parameters​
| Parameter | Default | Description |
|---|---|---|
bumpMapEnabled | false | Set automatically when a bump map is bound. |
pbr_bumpSampler | Required | Bump map with linear height values in the red channel. |
bumpFactor | 1 | Bump strength. Zero disables the effect. |
bumpUVSet | 0 | UV set index (0 or 1). |
bumpUVTransform | Identity matrix | 3×3 transform for bump-map UVs. |
HAS_BUMPMAP | false | Compiles height sampling into the shader. |
Remarks​
- When a material also has a normal map, the bump map perturbs the mapped normal.
- glTF bump maps are supported, see
EXT_materials_bump.