Skip to main content

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.

GitHub
0.0s
Both spheres have the same shape and material color. The sphere on the right adds a bump map.

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​

ParameterDefaultDescription
bumpMapEnabledfalseSet automatically when a bump map is bound.
pbr_bumpSamplerRequiredBump map with linear height values in the red channel.
bumpFactor1Bump strength. Zero disables the effect.
bumpUVSet0UV set index (0 or 1).
bumpUVTransformIdentity matrix3×3 transform for bump-map UVs.
HAS_BUMPMAPfalseCompiles height sampling into the shader.

Remarks​