CesiumGS / CesiumGS/cesium

Can we reduce polyline smears on steep slopes?

Open
#6,691 1 comment 0 reactions 1 assignee Claimed by @likangning93 View on GitHub
category - polyline type - enhancement
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:

![smear](https://user-images.githubusercontent.com/5395255/41438455-4ffe3370-6ff5-11e8-96db-d2ef465f8a0e.JPG)

```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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.