Skip to content

fix(core): turn GlobeView meter-offset normals to the origin's frame (2/2) - #10915

Open
charlieforward9 wants to merge 8 commits into
masterfrom
fix/globe-meter-offset-normals
Open

charlieforward9 wants to merge 8 commits into
masterfrom
fix/globe-meter-offset-normals

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Follow up of #10252. Part 2 of 2, follows #10914.

In GlobeView, project_position places meter offsets in the east, north and up of the coordinate origin, but project_normal rotates by the frame at geometry.position. SimpleMeshLayer, ScenegraphLayer (composed model matrix) and PointCloudLayer call it before setting that position, so Tile3DLayer glTF and point-cloud tiles are lit as if at the north pole, with NaN normals on WebGPU.

Change List

  • project_needs_rotation: use the origin's frame for globe meter offsets
  • SimpleMeshLayer, ScenegraphLayer: update composed-branch comments
  • WGSL geometry.position: start at (0, 0, 1, 0) like GLSL
  • Unit tests
  • Documentation
  • Upgrade guide

Verified with headless unit tests on WebGL2 and WebGPU (the new test fails on #10914) and the globe render tests.

charlieforward9 and others added 3 commits October 23, 2026 17:00
project_get_orientation_matrix returned columns pointing west and south.
project_position_to_clipspace and project_normal rotate meter offsets by
it, so below zoom 12 GlobeView turned every offset half a turn about the
local up direction: SimpleMeshLayer and ScenegraphLayer meshes, ColumnLayer
angles, and IconLayer and TextLayer with billboard: false. They turned back
at the zoom-12 switch to WebMercatorViewport. The meter-offsets projection
negated x and y to compensate, so it was already correct.

The matrix now returns east, north and up columns, and the meter-offsets
projection no longer negates. At the poles, east is +x, the limit of east
along longitude 0, so a meter-offset origin exactly at a pole now matches
its neighbours instead of being turned half a turn.

The WGSL version passed its select() arguments in the wrong order: away
from the poles x was always +x, and at the poles normalize(vec3(0.0))
gave NaN, including for normals that SimpleMeshLayer and ScenegraphLayer
project before setting geometry.position. It now matches the GLSL.

The CPU mirrors of the frame in @deck.gl/extensions and deck-gpu-layers
follow the new convention; their results are unchanged away from the
poles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At a pole, project_get_orientation_matrix returns the limit of east along
the longitude that up retains: GlobeViewport.projectPosition leaves a tiny
horizontal component, so an origin at [90, 90] has east +y. Only an up
exactly on the polar axis takes +x. Say so in the shader comments, the
project docs, the upgrade guide and the deck-gpu-layers mirror, and test
both poles at nonzero longitudes on WebGL and WebGPU. WGSL test literals
now use exponent notation so that those tiny components survive.

The GlobeView SimpleMeshLayer test now finalizes its Deck in a finally
block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With coordinateSystem: 'meter-offsets' on GlobeView, project_position
places positions in the east, north and up of the coordinate origin, but
project_normal rotated normals by the frame at geometry.position.
SimpleMeshLayer and ScenegraphLayer (composed model matrix) and
PointCloudLayer call project_normal before they set geometry.position. In
GLSL that position starts at (0, 0, 1), so the normals stayed in the
globe's common axes and were lit as if the mesh stood at the north pole;
in WGSL it starts at zero and the normals were NaN. This covers
Tile3DLayer glTF and point-cloud tiles.

project_needs_rotation now uses the frame at project.commonOrigin in
PROJECTION_MODE_GLOBE_METER_OFFSETS, in GLSL and WGSL, so normals,
project_position_to_clipspace offsets and PathLayer extrusion turn with
the same frame as the positions, wherever geometry.position is set.
Plain GLOBE and all non-globe modes are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 23, 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

Makes globe meter-offset normals use the coordinate origin’s east, north and up directions, matching positions.

  • GlobeView meter-offset normals use the coordinate origin's frame.
  • WGSL keeps early GlobeView Cartesian normals in their common-space direction.

Reviews (5) · Last reviewed commit: "Merge branch 'fix/globe-orientation-matr..." · Reviewed by Greptile

@charlieforward9
charlieforward9 force-pushed the fix/globe-meter-offset-normals branch from 9f9fb5b to 70d4d1d Compare October 23, 2026 22:29
charlieforward9 and others added 3 commits October 23, 2026 18:50
The GLSL geometry module starts geometry.position at (0, 0, 1, 0); the
WGSL project module declared its own geometry without an initializer, so
the position started at zero. SimpleMeshLayer and ScenegraphLayer with a
composed model matrix call project_normal before they set the position,
and with coordinateSystem: 'cartesian' (globe-centered) on GlobeView,
project_normal rotated by project_get_orientation_matrix(vec3(0.0)),
which normalizes a zero vector: their normals were NaN on WebGPU. GLSL
takes the polar-axis case there and leaves them unrotated.

The WGSL geometry now starts with the same position. Every other WGSL
reader either sets geometry.position first or only reads its x, y or w,
which are zero in both, so only the unset z changes, as in GLSL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@charlieforward9 charlieforward9 changed the title fix(core): turn GlobeView meter-offset normals to the origin's frame fix(core): turn GlobeView meter-offset normals to the origin's frame (2/2) Oct 26, 2026
charlieforward9 and others added 2 commits October 26, 2026 00:42
…device

A Deck created without a device builds its own WebGL device in the shared
headless page, which broke uniform block layouts for later test files
(ScreenGridLayer, BrushingExtension, ArcLayer and others). Use the shared
1x1 test device, center the view on each expected location, and keep the
mesh below the camera.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coveralls

coveralls commented Oct 26, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 84.16% — fix/globe-meter-offset-normals into fix/globe-orientation-matrix. No base build found for fix/globe-orientation-matrix.

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the current head. CI passes, Greptile found no actionable issue, and there are no unresolved review threads. I found no blocker; this looks ready for approval. It is stacked on #10914, so merge after its base lands.

@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
29 of 30 tasks
Comment thread docs/upgrade-guide.md

`project_get_orientation_matrix` now returns east, north and up columns, and the same matrix in WGSL; WebGPU previously ignored the location. At a pole, east is its limit along the position's longitude, and the common-space x axis only when the position lies exactly on the polar axis.

With `coordinateSystem: 'meter-offsets'`, `project_normal` now turns normals to the east, north and up of the coordinate origin, as `project_position` does for positions. In `GlobeView`, `SimpleMeshLayer`, `ScenegraphLayer` and `PointCloudLayer`, including `Tile3DLayer` glTF and point-cloud tiles, previously lit them as if they stood at the north pole (NaN on WebGPU).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Upgrade guide just needs to note what a user needs to change for the upgrade.

For this PR and the one below it, how probable is it a user was applying something they need to now change due to this change?

If it's a noteworthy bug fix then it can go in what's new.

@chrisgervang

Copy link
Copy Markdown
Collaborator

Could we see a before/after of this fix? I assume it affects lighting since this is correcting normals, but there may be other visual changes too

Base automatically changed from fix/globe-orientation-matrix to master November 7, 2026 21:51
@ibgreen ibgreen added the bug label Nov 21, 2026

@athomct athomct left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please rebase on master. #10914 is merged, and this branch conflicts in four files. On master, the WGSL Geometry is now an alias of VertexGeometry in misc/geometry.ts. That struct has seven fields, and position is the first field. Update the geometry initializer in project.wgsl.ts to match it, or the WGSL does not compile.

I agree with chrisgervang on the upgrade guide. The project_normal change is a lighting bug fix, and users do not need to change their code. Please move it to docs/whats-new.md. Please also add the before/after image that he asked for.

// Start like the GLSL geometry module: w = 0 marks the position as not yet set, and a normal
// projected before a layer sets it (with a composed model matrix) is not rotated, rather than
// rotated by the orientation of a zero vector.
var<private> geometry: Geometry = Geometry(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On master, Geometry is VertexGeometry. Its field order is position, worldPosition, worldPositionAlt, normal, uv, pickingColor, screenSpaceOffset. After the rebase, write the initializer in that order with seven fields.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants