CesiumGS / CesiumGS/cesium

Scene.specularEnvironmentMaps never activates SPECULAR_IBL: ImageBasedLightingPipelineStage checks model.useDefaultSpecularMaps instead of imageBasedLighting.useDefaultSpecularMaps

Open Beginner friendly
#13,752 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

**Version:** 1.143 (present on current main)

**Bug:** In `packages/engine/Source/Scene/Model/ImageBasedLightingPipelineStage.js`, the spherical-harmonics branch reads the flag from the `ImageBasedLighting` instance (line 90):

```js
} else if (imageBasedLighting.useDefaultSphericalHarmonics) {
```

but the parallel specular branch reads it from the model (line 123):

```js
} else if (model.useDefaultSpecularMaps) {
```

`Model` has no `useDefaultSpecularMaps` property — the getter lives on `ImageBasedLighting` (`ImageBasedLighting.js`, where it returns true once the scene's default specular cube map is ready). The expression is always `undefined`, so the `SPECULAR_IBL` define is never added for models that should adopt the scene-level default map.

**Effect:** setting `Scene.specularEnvironmentMaps` (the shared KTX2 route documented since 1.53) has no effect on `Model` rendering unless a per-model `specularEnvironmentMaps` is also set. Fully metallic glTF materials render near-black even with a valid scene-level environment map, because they get no specular IBL and metals have no diffuse term.

**Repro:** load any glTF model with `metallicFactor: 1.0`, set `scene.specularEnvironmentMaps` to a valid KTX2 specular map, leave per-model IBL defaults. The model stays black; with the one-line fix below it renders with reflections.

**Fix (verified locally via a package patch on @cesium/engine 26.1.0):**

```diff
- } else if (model.useDefaultSpecularMaps) {
+ } else if (imageBasedLighting.useDefaultSpecularMaps) {
```

Happy to open a PR if useful.

Contributor guide

Open the contributing guide

Research direction

Start in packages/engine/Source/Scene/Model/ImageBasedLightingPipelineStage.js and compare the specular branch with the spherical-harmonics branch. Check the useDefaultSpecularMaps getter in ImageBasedLighting.js, then reproduce with a metallic glTF, Scene.specularEnvironmentMaps, and a valid KTX2 map. Done means the scene-level map activates SPECULAR_IBL and the model renders reflections.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.