Skip to main content

Index of refraction

Index of refraction controls the optical contrast at a dielectric boundary and influences reflection and transmitted light.

GitHub
0.0s
Follow a checkerboard edge through both spheres. The thin sphere is on the left. The right sphere has a refractive index of 2.42 and a thickness of 1.

Configuration​

import {Model} from '@luma.gl/engine/api';
import {createPBRMaterial, type PBRMaterial} from '@luma.gl/engine/materials';

const material: PBRMaterial = createPBRMaterial(device, {
uniforms: {
ior: 1.5,
metallicRoughnessValues: [0, 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​

ParameterDefaultDescription
ior1.5Index of refraction of the dielectric material.

Enable USE_MATERIAL_EXTENSIONS on custom models. The glTF importer enables it automatically.

See Using PBR materials for material setup.

Remarks​