Visitar URL original
fix(core): keep the cartesian z scale continuous at zoom 12 by mfrnd · Pull Request #10853 · visgl/deck.gl · GitHub
Skip to content

fix(core): keep the cartesian z scale continuous at zoom 12 - #10853

Open
mfrnd wants to merge 3 commits into
visgl:masterfrom
mfrnd:fix/7064-cartesian-z-zoom-12-step
Open

mfrnd wants to merge 3 commits into
visgl:masterfrom
mfrnd:fix/7064-cartesian-z-zoom-12-step

Conversation

@mfrnd

@mfrnd mfrnd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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. In WEB_MERCATOR mode, 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: no second-order z correction for cartesian positions
    • Removed rather than made center-relative below zoom 12: unitsPerMeter2 is per meter, but cartesian y offsets are in common units, so from zoom 12 it changed z by less than a millionth across the view
  • Unit tests: projected z on the GPU at zoom 11.99 and 12, latitudes 80 to -80, and the uniform on both sides of zoom 12

Ran lint, build, the core shaderlib and viewport, extensions and TerrainLayer headless tests, and the terrain render tests on WebGL.


Note

Low Risk
Low risk adjustment to viewport uniforms for cartesian coordinate systems with comprehensive GPU and uniform tests.

Overview
Removes the second-order z correction (commonUnitsPerWorldUnit2) for cartesian coordinates in viewport projection uniforms.

Previously, using unitsPerMeter2 for cartesian coordinates scaled with absolute y coordinates below zoom 12, producing an elevation step discontinuity when transitioning to offset mode at zoom 12. Setting this correction to zero ensures continuous z scaling across zoom levels with negligible effect on projection accuracy.

Reviewed by Cursor Bugbot for commit 1dec866. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Removes the second-order elevation correction for cartesian positions, keeping their elevation scale consistent across zoom 12.

  • Cartesian heights stay steady when Web Mercator crosses zoom 12.

Reviews (3) · Last reviewed commit: "fix(core): drop the cartesian second-ord..." · Reviewed by Greptile

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 83.704% (+0.001%) from 83.703% — mfrnd:fix/7064-cartesian-z-zoom-12-step into visgl:master

@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
16 of 47 tasks
mfrnd added 2 commits November 7, 2026 14:39
unitsPerMeter2 is the change of the z scale per meter of y offset, but
'cartesian' offsets are in common units, so from zoom 12 the term
changed z by less than a millionth across the view, and the CPU
projectPosition never applied it. Drop it in every mode rather than
below zoom 12 only, which also removes the second check for offset
mode. The CPU continuity test checks the uniform, on WebGPU too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants