[Bug] Division by zero in `TripsLayer` if 2 consecutive coordinates share the same location
@Pessimistress is already working on this.
Since Apr 25, 2022.
- Dominant language
- TypeScript
- Stars
- 14.6k
- Forks
- 2.3k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 42
Description
Description
Originally reported on Slack, but I'm moving it here for exposure:
The bug is in:
When 2 consecutive coordinates share the same coordinate, they’ll have vPathLength of zero, so the clipping of the line does not work and the point is colored (due to vTime being calculated from a zero division)
We use tripslayer with additive blending for light-paths and this leads to fireflies along the path.
My hotfix is vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / ((vPathLength > 0.0) ? 1.0 : vPathLength); but there might be better ways to fix it.
This line could also probably replaced by a mix(instanceTimestamps, instanceNextTimestamps, (vPathLength > 0.0) ? (vPathPosition.y / vPathLength) : 0.5) to make it more explicit (for human reader and shader compiler alike?)
//Edit: I actually ran into precision issues with the code above. I'm now using this:
highp float pathPositionYInstancePercentage = (vPathLength > 0.0) ? (vPathPosition.y / vPathLength) : 0.5;
vTime = mix(instanceTimestamps, instanceNextTimestamps, pathPositionYInstancePercentage);
Flavors
- React
- Python/Jupyter notebook
- MapboxLayer
- GoogleMapsOverlay
- CartoLayer
- DeckLayer/DeckRenderer for ArcGIS
Expected Behavior
Do not divide by zero and provide a sane vTime
Steps to Reproduce
Create a TripsLayer with the same location repeated twice for waypoints on the path coordinates / positions.
Environment
n/a
Logs
n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.