Compute inverse transpose matrix for instanced models
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Both the old `ModelInstanceCollection` and the new `InstancingPipelineStage` handle instancing, but for normals they re-use the model view matrix without computing the inverse transpose. If the model matrix contains any scaling/shearing, then this is not accurate.
That said, since instancing transforms come from an attribute, it's a bit trickier than usual. Since attribute locations are limited, we'd probably want to do this in the shader. This would involve:
* Since WebGL 1 doesn't support `inverse()`, we'd need a custom `czm_inverse()` (or perhaps `czm_inverseTranspose()`) function
* GLSL doesn't have `transpose()`, though this can be emulated by multiplying on the right (i.e. `vector * matrix`). Though it could also be emulated with a function.
Contributor guide
Research direction
Start by reading the instancing paths in ModelInstanceCollection and InstancingPipelineStage, then inspect how their shaders transform normals. Account for WebGL 1 limitations by considering the custom czm_inverse() or czm_inverseTranspose() approach described in the issue. Done means normals remain accurate when the model matrix includes scaling or shearing.
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
- 45/100