fix: correct coordinate rendering offset at maximum zoom via fp64 viewport center#2817
Open
fix: correct coordinate rendering offset at maximum zoom via fp64 viewport center#2817
Conversation
|
…ax zoom At high zoom levels (>12) in LNGLAT_OFFSET mode, the shader subtracts the viewport center from vertex positions. Since uniforms are float32, the viewport center loses its fp64 low part (fp64LowPart(center) ≈ 6e-6 degrees), causing an 18-36 pixel rendering offset at zoom 21-22. The fix adds a u_ViewportCenterLow uniform containing fp64LowPart(center), which is subtracted from the computed offset in the shader. This achieves full double-precision accuracy for the center subtraction. Changes: - scene_uniforms.glsl: Add vec2 u_ViewportCenterLow - projection.glsl: Subtract u_ViewportCenterLow in LNGLAT_OFFSET path - ICoordinateSystemService.ts: Add ViewportCenterLow to enum and interface - CoordinateSystemService.ts: Compute viewportCenterLow = fp64LowPart(center) - ShaderUniformPlugin.ts: Pass u_ViewportCenterLow in UBO data and uniforms Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix severe offset in drawPolygon cursor and rendering points
fix: correct coordinate rendering offset at maximum zoom via fp64 viewport center
Feb 25, 2026
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.
At maximum zoom levels on AMap (zoom 21+), drawn points render 20–40px away from the actual click position. The
LNGLAT_OFFSETcoordinate system (active when zoom > 12) uses fp64 split encoding for vertex positions, but the viewport center passed asu_ViewportCenteris afloat32uniform — silently droppingfp64LowPart(center) ≈ 6e-6°, which maps to ~18–36px error at zoom 21–22.Changes
scene_uniforms.glsl: Addvec2 u_ViewportCenterLowto the UBO struct (fits in existing 96-float buffer)projection.glsl: In theLNGLAT_OFFSETpath, subtractu_ViewportCenterLowfrom the computed offset to achieve full double-precision center subtraction:CoordinateSystemService: ComputeviewportCenterLow = [center[0] - Math.fround(center[0]), center[1] - Math.fround(center[1])]on everyrefresh()ICoordinateSystemService: AddViewportCenterLowtoCoordinateUniformenum andgetViewportCenterLow()to the interfaceShaderUniformPlugin: Retrieve and packu_ViewportCenterLowinto the UBO data array and WebGL1 uniforms fallbackOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.