question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TileBoundingRegion.distanceToCamera is inaccurate when camera is on opposite side of the globe

See original GitHub issue

TileBoundingRegion.distanceToCamera is inaccurate when the camera is on the opposite side of the globe.

In this sandcastle rectangle A and B are on the opposite side of the globe. Rectangle A is clearly closer to the camera but the distance results say otherwise:

Distance to A: 18218478.748910885
Distance to B: 14805027.338562964

image

After stepping through TileBoundingRegion.distanceToCamera, the problem is that the distance from each plane (west, south, east, north) is computed using the dot product of the plane normal and a vector from one of the corners to the camera. In this specific view the distance from the east plane is much greater for rectangle A than rectangle B because the plane normal and the camera vector are more closely aligned, a situation that can only happen when the camera is on the opposite side of the globe.

This bug impacts screen space error calculations for 3D Tiles. It doesn’t impact terrain because terrain uses Horizon Culling, which is being added to 3D Tiles Next as well (see the tile metadata semantic TILE_HORIZON_OCCLUSION_POINT)

I don’t have any great suggestions for fixing this right now. One idea is to use an OBB distance check based on certain heuristics. But most likely the math can just be fixed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
kringcommented, May 12, 2021

That’s a good question, and I don’t know the answer. Generally, small (high detail) quadtree tiles in a geographic projection are going to be tightly bounded by an OBB (assuming it’s computed well), but larger (low detail) ones will be pretty poor because of Earth curvature and because tiles with a fixed width in longitude degrees are narrower at their side closest to the poles. So I suspect the biggest benefit from using distance-to-region will be at sort of medium zoom levels.

I just did some really quick and dirty inspection of this, and yeah, the above looks to be correct. The distance-to-region check is only being used in tiles at levels 1-4. It makes a pretty big difference in those tiles, though, estimating the distance to be 30%-ish greater in some cases. We should probably do some deeper analysis before removing the distance-to-region computation entirely, though, or even before restricting it to coarse tiles.

1reaction
pjcozzicommented, May 11, 2021

@lilleyse is it correct that a worse case improvement is to runtime convert region to the (conservative) approximate OBB and then use the OBB for culling? If so, maybe we should put that in a branch now for folks to move forward with while we work on the complete fix?

@ebogo1 I would suggest getting to go a good stopping point with KTX2 and then taking a look at this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Globe.pick gives wrong results when the camera is tilted, and ...
C) I can imagine a situation when two (or more) triangles in a tile (with a front face in the opposite direction of...
Read more >
cesium/CHANGES.md - UNPKG
135, - Fixed an issue in `TileBoundingRegion.distanceToCamera` that caused incorrect results when the camera was on the opposite site of the globe.
Read more >
AnalyticalGraphicsInc - Bountysource
TileBoundingRegion.distanceToCamera is inaccurate when the camera is on the opposite side of the globe. In this sandcastle rectangle A and B are on...
Read more >
CHANGES.md · feature/rebased-gpx · mirrors / cesiumgs / cesium ...
#9692; Fixed an issue in TileBoundingRegion.distanceToCamera that caused incorrect results when the camera was on the opposite site of the globe.
Read more >
~hepeng/pro-yuanshi-new.git - Gitblit
n * <br /><br />\n * On the other hand, a {@link RuntimeError} indicates an ... function(distanceToCamera, density) {\n var scalar = distanceToCamera...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found