Repository navigation
fix(core): turn GlobeView meter-offset normals to the origin's frame (2/2) - #10915
charlieforward9 wants to merge 8 commits into
Conversation
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]>
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryMakes globe meter-offset normals use the coordinate origin’s east, north and up directions, matching positions.
Reviews (5) · Last reviewed commit: "Merge branch 'fix/globe-orientation-matr..." · Reviewed by Greptile |
9f9fb5b to
70d4d1d
Compare
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]>
…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]>
ibgreen
left a comment
There was a problem hiding this comment.
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.
|
|
||
| `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). |
There was a problem hiding this comment.
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.
|
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 |
athomct
left a comment
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
Follow up of #10252. Part 2 of 2, follows #10914.
In
GlobeView,project_positionplaces meter offsets in the east, north and up of the coordinate origin, butproject_normalrotates by the frame atgeometry.position.SimpleMeshLayer,ScenegraphLayer(composed model matrix) andPointCloudLayercall it before setting that position, soTile3DLayerglTF 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 offsetsSimpleMeshLayer,ScenegraphLayer: update composed-branch commentsgeometry.position: start at(0, 0, 1, 0)like GLSLVerified with headless unit tests on WebGL2 and WebGPU (the new test fails on #10914) and the globe render tests.