mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.19k stars 2.22k forks source link

North pole cap and Greenland have holes with exaggerated extrusions #12037

Closed AlexanderBelokon closed 2 years ago

AlexanderBelokon commented 2 years ago

mapbox-gl-js version: 2.9.1

browser: Firefox 101.0.1

Steps to Trigger Behavior

  1. Login to Studio
  2. Create a new style (with globe projection by default)
  3. 3D -> 3D Terrain -> Enable terrain -> On
  4. 3D -> 3D Terrain -> Exagerration -> 1000
  5. Look at the area around the pole, slightly moving the viewport back and forth
  6. Notice that Greenland sometimes appears to have a hole in it, possibly when a specific tile is used for a part of it
  7. Notice that the polar cap moves further inside the globe when exaggeration is increased

Link to Demonstration

Shared style

holy-pole

pole-hole

https://user-images.githubusercontent.com/2198527/175383574-88e05138-303d-449b-a4cf-39c7d22e83d3.mp4

https://user-images.githubusercontent.com/2198527/175384583-825fa272-4b53-4938-b2e8-80506d3523b2.mp4

Expected Behavior

Globe does not have holes

Actual Behavior

Globe has holes

AlexanderBelokon commented 2 years ago

I noticed that even without exaggerated terrain (and even without any extrusions at all) the seams that are apparent here (around the polar cap and above iceland) are sometimes visible as hairlines, sometimes only a few transparent dots here and there, sometimes as almost complete single-pixel transparent lines. Extrusions just make them easier to notice.

https://user-images.githubusercontent.com/2198527/175432229-6b3b6be3-32f0-44f9-a215-d2264f769189.mp4

SnailBones commented 2 years ago

I noticed that even without exaggerated terrain (and even without any extrusions at all) the seams that are apparent here (around the polar cap and above iceland) are sometimes visible as hairlines, sometimes only a few transparent dots here and there, sometimes as almost complete single-pixel transparent lines. Extrusions just make them easier to notice.

This looks like https://github.com/mapbox/mapbox-gl-js/issues/11858, good to note that the issue is heightened with terrain.

AlexanderBelokon commented 2 years ago

I think this issue is a result of two problems:

1) When creating tiles for greenlandish latitudes, normals for boundary points are calculated without taking into account neighboring tiles, making them too perpendicular to the globe, and as a result, accumulating errors with any exagerration. This might be fixed if we take more points on the other side of the tile into accont and make sure that normals on both sides of the tile boundary are pointing in the same direction.

2) When creating the cap for the pole, the cap's origin is located somewhere close to the pole, and to make it aligned with the rest of the sphere it is given a slight negative altitude that is amplified by the exagerration. This may be fixed if we move the origin for each of the cap's triangles to the outer rim of the cap, making negative altitude unnecessary.