CesiumGS / CesiumGS/cesium

Wrong normals for instanced models with node scaling in glTF

Open
#11,477 2 comments 0 reactions 0 assignees View on GitHub
category - 3d tiles type - bug
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`

![Cesium instances normal issue](https://github.com/CesiumGS/cesium/assets/5597569/bea559ec-4c3c-4243-be88-8f3d32fbca3b)

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

![Cesium instances normal issue 2](https://github.com/CesiumGS/cesium/assets/5597569/5534ba2d-d75b-45a4-9513-ab0c016305ff)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.