Skip to content

Environment Maps

Related references:

Environment maps are mainly used to improve reflections and overall material quality, especially for PBR glTF models.

Create an Environment Map from HDR

js
const envMap = await api.createEnvMapByHDR('/assets/studio.hdr');

Passing an ArrayBuffer is also supported.

Apply It to a Model

js
const model = await api.getObject('rabbit');
const envMap = await api.createEnvMapByHDR('/assets/studio.hdr');

await api.useEnvMapForObj(model, envMap, 1);

The third parameter is the intensity. Its default value is 1.

Suitable Targets

The current implementation traverses the target object and its children, then writes the environment map to their materials. It is most effective on model-type objects.

Environment maps usually need to be tuned together with:

  • directional light / ambient light
  • tone mapping
  • anisotropy

That combination tends to produce more stable results.

Recommendations

  1. Use HDR files that are well compressed and appropriately sized whenever possible.
  2. Do not apply environment maps blindly to every object. Start with your key models first.
  3. If you only want a more immersive background, use a panorama first. If you want a model to feel more like a real material, then add an environment map.