Can we reduce polyline smears on steep slopes?
- Dominant language
- JavaScript
- Stars
- 15.8k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Polylines on terrain smear on steep slopes, since it's similar to a shadow volume:

```javascript
var viewer = new Cesium.Viewer('cesiumContainer');
var positions = Cesium.Cartesian3.fromDegreesArray([
-122.17580380403314, 46.19984918190237,
-122.17671567204553, 46.196577275143326,
-122.17190167749244, 46.19583668275485
]);
viewer.entities.add({
polyline : {
positions : positions,
width : 32,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.2,
color : Cesium.Color.BLUE
}),
clampToGround : true
}
});
viewer.camera.lookAt(positions[0], new Cesium.Cartesian3(0.0, 0.0, 5000.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
```
(Note that this won't work until https://github.com/AnalyticalGraphicsInc/cesium/pull/6689 is merged)
We compute local terrain slopes for materials on ground primitives using the globe depth texture (this is something like screen-space partial derivatives), so I wonder if we could use these to help reduce smear.
Currently the algorithm for determining if a fragment is part of the polyline checks the distance between the fragment's position (derived from globe depth texture) and a plane, but if we had a local terrain slope we could do a ray-plane check instead of point-plane distance.
In addition to effectiveness we'd also want to evaluate the performance hit for this. Since it's much less noticeable for narrower lines, maybe it can be a toggleable option if it's too slow.
See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Shaders/ShadowVolumeAppearanceFS.glsl#L28
Contributor guide
Assessment
This issue has not been assessed yet.