Repository navigation
Conversation
Since the viewport center is the geospatial origin of 'cartesian' positions below zoom 12, their second-order z correction (commonUnitsPerWorldUnit2) is no longer zero away from the equator. project_offset_ multiplies it by the y offset from the origin, but WEB_MERCATOR mode does not offset positions, so below zoom 12 it used the absolute common y: 1,000 m at the viewport center was drawn as 1,000.40 m at latitude 80 and 999.95 m at latitude -80, and as 1,000.00 m from zoom 12. Apply the correction in WEB_MERCATOR_AUTO_OFFSET mode only. A GPU test projects 1,000 m at the viewport center at zoom 11.99 and 12, at latitudes 80, 46.2, 0, -46.2 and -80.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #7064. Follow-up to #10790, from ibgreen's note.
Background
Since #10790,
'cartesian'positions below zoom 12 use the viewport center as geospatial origin, so their second-order z correction is nonzero away from the equator. InWEB_MERCATORmode,project_offset_multiplies it by the absolute common y instead of the offset from the center: below zoom 12, 1,000 m at the viewport center is drawn as 1,000.40 m at latitude 80 and 999.95 m at latitude -80, from zoom 12 as 1,000.00 m.Change List
calculateViewportUniforms: cartesian z correction inWEB_MERCATOR_AUTO_OFFSETmode onlyunitsPerMeter2is per meter, but cartesian y offsets are in common units, so even from zoom 12 it changes z by less than a millionth across the viewRan lint, build, the core shaderlib and viewport, extensions and TerrainLayer headless tests, and the terrain render tests on WebGL.
Note
Medium Risk
Touches core projection uniforms used by all cartesian/preprojected layers; behavior change below zoom 12 is intentional but could affect subtle elevation rendering.
Overview
Fixes a discontinuity at zoom 12 for
COORDINATE_SYSTEM.CARTESIANgeometry (e.g. terrain meshes) where z is in meters but x/y are already in common space.In
calculateViewportUniforms, the cartesian branch no longer always setscommonUnitsPerWorldUnit2fromunitsPerMeter2. The second-order z correction is applied only whenprojectionModeisWEB_MERCATOR_AUTO_OFFSET. In plainWEB_MERCATOR(zoom < 12), it is zeroed so the shader does not scale that term by absolute common y—which had caused latitude-dependent elevation error and a step when the viewport switches modes at zoom 12.Adds a GPU regression test that projects a 1000 m z at the viewport center across zoom 11.99 vs 12 and latitudes 80° to −80°, asserting recovered elevation stays ~1000 m.
Reviewed by Cursor Bugbot for commit e2be793. Bugbot is set up for automated code reviews on this repo. Configure here.