Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shift horizon towards center to reduce the number of tiles loaded #10304

Merged
merged 7 commits into from
Jan 26, 2021

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Jan 20, 2021

This shifts the horizon down a bit to reduce the number of tiles in highly pitched views. Everything beyond the new horizon is clipped. The skybox is shifted down to meet the horizon.

The horizon is currently shifted 10% of the distance from the true horizon to the center. Specifying the shift as a fraction keeps the horizon at the same real-world locations as pitch changes. The value is not user-configurable right now but we may want to expose it once fog lands. Fog might also make it possible to shift the horizon even further. By blending the map with the sky the sharp edge might be less jarring.

The number of tiles dropped depends on the view. This view loads 20% less tiles:

Screen Shot 2021-01-20 at 11 23 39 AMScreen Shot 2021-01-20 at 11 23 33 AM

The perspective of the map is not affected.

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Shift horizon down slightly to reduce the number of tiles loaded for highly-pitched maps.</changelog>

@ansis ansis added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Jan 20, 2021
Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good and is very simple and effective. Once we have tests passing this should be good to go. Have you been able to run performance benchmarks on this? We have a fixture on heavily pitched views for 3d.

const farZ = furthestDistance * 1.01;

// Move the horizon closer to the center. 0 would not shift the horizon. 1 would put the horizon at the center.
const horizonShift = 0.10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity I tested out other values, I think 10% is a good choice and great compromise. Trying to go higher than that starts showing horizon clipping, and is being visually distracting.

src/symbol/collision_index.js Outdated Show resolved Hide resolved
@karimnaaji
Copy link
Contributor

karimnaaji commented Jan 22, 2021

@ansis I updated the 3d fixture and ran this branch against v2.0.1:

Screen Shot 2021-01-22 at 11 26 58 AM

Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karimnaaji karimnaaji merged commit d0fbc98 into main Jan 26, 2021
@karimnaaji karimnaaji deleted the shift-horizon branch January 26, 2021 01:45
@astojilj
Copy link
Contributor

astojilj commented Jan 26, 2021

@ansis , @karimnaaji

The value is not user-configurable right now but we may want to expose it once fog lands

Wouldn't that be already configurable by specifying top padding value (though that would shift down center of map)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce number of tiles in really pitched views by shifting horizon + use pitch in lod calculation
3 participants