Skip to content

Spike: high-zoom precision via per-tile reference point (superseded by #559) - #558

Closed
kylebarron wants to merge 4 commits into
mainfrom
kyle/fix-zoom-precision-issues
Closed

kylebarron wants to merge 4 commits into
mainfrom
kyle/fix-zoom-precision-issues

Conversation

@kylebarron

@kylebarron kylebarron commented May 19, 2026 •

Copy link
Copy Markdown
Member

This branch: lots of jitter, and in particular per tile independent jitter so we have little gaps between tiles. Jitter noticeably starts above ~z16

Screen.Recording.2026-05-20.at.1.28.10.PM.mov

Closed without merging — this is a record of an approach to #512 that did not work. The working fix is #559. See that PR (and dev-docs/coordinate-systems.md on it) for the full analysis.

What this tried

Attack the high-zoom jitter (#512) by keeping mesh vertex magnitudes small: store each vertex as an offset from a per-tile reference point (the tile centroid in EPSG:3857 meters) instead of an absolute coordinate, then add the reference back via the layer transform. Iterations on this branch (and follow-on experiments in the session that produced it):

  1. Offset subtraction in the mesh + per-tile reference baked into modelMatrix.translation.
  2. Per-tile coordinateOrigin (let deck.gl's auto-offset subtract it).
  3. Shared per-frame coordinateOrigin = viewport.center, per-tile shift in modelMatrix.translation.

Why it didn't work

  • Tile seams. Encoding a shared boundary vertex differently in adjacent tiles (e.g. +305 in tile A, −305 in tile B) makes the two tiles run different float32 arithmetic chains for the same physical point. The sub-pixel disagreement gets amplified by GPU rasterization coverage rounding into visible 1-px seams — which main does not have (it stores the same absolute value in both tiles, so they're bit-identical). The seam is structural to any per-tile encoding, regardless of where the reference shift lives.
  • No real precision win. Even when numerically sub-pixel, the auto-offset origin uniform (shaderCoordinateOrigin) is itself float32 at ~10² world-unit magnitude, leaving a ~1 m floor — indistinguishable from main.

What actually fixed it (#559)

Render the mesh in common space with an identity model matrix and coordinateOrigin = [0,0,0] (so shaderCoordinateOrigin is exactly Math.fround(viewport.center) and the camera-relative subtraction is Sterbenz-exact), plus fp64 attribute pairs for the vertex positions. Absolute common-space coords keep shared boundary vertices bit-identical → no seams. Full write-up in #559.

Related: #512

Captures the float32 quantization root cause and the split-precision /
per-tile reference-point fix for the tile path.
…512)

Computes the centroid of projectedCorners per tile so RasterLayer can
use it to split mesh vertex positions into a float32 offset plus a
float64 origin, preserving precision at high zoom.

Pure data addition; no consumer reads the new field yet.
* and a float64 origin to preserve precision at high zoom. Computed once
* per tile as the centroid of {@link RasterTileMetadata.projectedCorners}.
*
* See `dev-docs/specs/2026-05-19-high-zoom-precision-design.md` for the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before merging the PR, I think this is core enough to warrant a top-level dev-doc explainer. Perhaps it should be something like "projection handling" explaining not just high zoom precision handling, and in the future could be expanded with globe view information.

* See `dev-docs/specs/2026-05-19-high-zoom-precision-design.md` for the
* reasoning.
*/
referencePointMeters: Point;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Are we sure this is always going to be in meters?

When provided, vertex positions are stored as float32 offsets from the
reference point instead of absolute EPSG:3857 meters, eliminating the
~1 m quantization that causes high-zoom jitter on the GPU.

No consumer passes the prop yet; default (null) is the prior behavior.
props.reprojectionFns.inverseReproject !==
oldProps.reprojectionFns?.inverseReproject;

const refChanged =

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

spell out referencePointChanged

…512)

Folds tile.referencePointMeters (float64) into the modelMatrix
translation and passes it down to RasterLayer, so vertex positions in
the GPU buffer are small float32 offsets instead of full-magnitude 3857
meters. Eliminates sub-meter jitter at z16+ on high-resolution imagery.
@kylebarron kylebarron changed the title Kyle/fix zoom precision issues Spike: high-zoom precision via per-tile reference point (superseded by #559) May 20, 2026
@kylebarron

kylebarron commented May 20, 2026 •

Copy link
Copy Markdown
Member Author

Written by claude

Closing as superseded by #559. Keeping the branch and this PR as a record of the per-tile-reference approach that produced tile seams and didn't beat main's precision floor — see the PR description and #559 for the analysis.

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.

1 participant