Remove the dependency on ApproximateTerrainHeights from GroundPrimitive and GroundPolylinePrimitive
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Currently `GroundPrimitive` and `GroundPolylinePrimitive` set their shadow volume bounds based on `approximateTerrainHeights.json`, a file full of earth's min and max heights at different longitudes/latitudes. If a user has a custom terrain dataset or uses terrain exaggeration, these approximate heights no longer work and the ground geometry will be clipped.
To fix exaggeration, we could add a `height` vertex attribute and scale it by terrain exaggeration in the shader. This is a little tricky because there's no more room for attributes for polylines. We could oct encode one of the normals to make space but I don't know if that's a good idea. Another option is to use a uniform or batch table entry with the min and max height, but since the geometry is created in the worker after the batch table / uniforms is created, it doesn't know the values. Also we would need a geodetic surface normal to offset the vert in the right direction. I would prefer baking the exaggeration into the verts if possible. Would need some rearchitecting.
For custom terrain datasets, I don't know... the polyline geometry would have to be rebuilt whenever the terrain underneath it changes.
See https://github.com/AnalyticalGraphicsInc/cesium/issues/8436#issuecomment-565742993 for an example of polylines breaking.
Contributor guide
Research direction
Start by tracing GroundPrimitive and GroundPolylinePrimitive and their use of approximateTerrainHeights.json, then review the linked issue example for the clipping failure. The issue leaves the implementation approach unresolved and notes constraints around vertex attributes, uniforms, batch tables, and rebuilt polyline geometry; done would require removing the dependency while preserving correct behavior for terrain exaggeration and custom terrain datasets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100