Wrong normals for instanced models with node scaling in glTF
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
The attached archive contains a tileset with three contents:
- `Box.glb` is just the "Box" glTF sample model
- `boxScaled.i3dm` is an I3DM that contains a version of the box that scaled by a factor of 100 in x-direction, but defines a `SCALE_NON_UNIFORM` of `[0.01, 1.0, 1.0]`, resulting in a unit box to be rendered
- `boxScaled.glb` is a glTF asset that contains a version of the box that scaled by a factor of 100 in x-direction, and uses `EXT_mesh_gpu_instancing` with a `SCALE` of `[1.0, 1.0, 1.0]` (!), attached to a node with a scaling of `[0.01, 1.0, 1.0]` - also resulting in a unit box to be rendered
The non-uniform scaling of the **node** that refers to the `EXT_mesh_gpu_instancing` causes some error with the computation of the normals:
Bottom: `Box.glb`
Center: `boxScaled.i3dm`
Top: `boxScaled.glb`

The effect is highly dependent on the view direction...

This may be a hint that there's likely some place where the transformation of the normals with the transpose of the inverse of the modelview matrix does not properly take into account the matrix of the node that the instancing extension is attached to...
The archive with the tileset, tiles, and a Sandcastle for quick tests:
[CesiumJS_instancing_normal_issue.zip](https://github.com/CesiumGS/cesium/files/12371110/CesiumJS_instancing_normal_issue.zip)
Contributor guide
Research direction
Start with the attached CesiumJS_instancing_normal_issue.zip and its Sandcastle reproduction, comparing Box.glb, boxScaled.i3dm, and boxScaled.glb. Trace how node scaling and EXT_mesh_gpu_instancing affect normal transformation, then verify that the scaled glTF instance has correct normals across view directions and matches the reference rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100