Repository navigation
test(render): render PathStyleExtension dash cases under GlobeView - #10664
Conversation
|
There was a problem hiding this comment.
Why is there a bump in the lower two lines
There was a problem hiding this comment.
Good catch. It is not a dash artefact: the whole GlobeView half is rendered about 4% larger than the MapView half and shifted ~5 px south, so the two southern paths (at −90/−150 px from centre) land 9–12 px lower on the globe side while the northern ones happen to line up (measured row centres: map 74.5/134.5/314.5/374.5 vs globe 74.5/136.5/323.5/386.5).
What I found tracking it down:
- CPU math is exact.
GlobeViewport.projectandWebMercatorViewport.projectagree to within 0.03 px for these lines at zoom 10 and 12, so the zoom adjustment / camera placement is not the cause. - It comes from the vertex shader's
project_globe_. A probe withScatterplotLayerpoints at ±30…±210 px offsets in a full-widthGlobeView:- SF, zoom 12, LNGLAT: uniform ~3.9% magnification (zoom 10: ~0.9%)
- SF, zoom 12,
METER_OFFSETS(origin projected on the CPU, no per-vertex trig): pixel-identical to MapView - (0, 0), zoom 12, LNGLAT: pixel-identical to MapView
- lng −122.4 / lat 0: ~0.9%; lng 0 / lat 37.78: ~3.1%
- Mechanism: SwiftShader's fp32
sin/coshave an absolute error of roughly 5e-5 (Vulkan only guarantees 2^-11). That displaces the computed sphere position by a constant ~0.015 common units. The radial component moves the surface toward the camera, which at 1.5 viewport heights turns into a uniform perspective scale; the tangential component is the constant shift. Because the error is constant across the tiny visible patch, it looks like scale + offset rather than noise. Hardware GPUs are ~1 ulp here, so on real devices this should be sub-pixel.
This is also the real reason globe goldens have needed the looser 0.985 threshold (the old "tessellation" comment was wrong). f7aaa69 documents it on withGlobeSideBySide so the next reader of these images isn't puzzled. Happy to instead move the paths closer to the centre or use METER_OFFSETS geometry if you'd prefer the seam to be visually clean; I kept LNGLAT since that is what users draw.
Generated by Claude Code
There was a problem hiding this comment.
I'm not sure.. by bump do you mean the dashes appear to have different widths?
(Btw, Claude will hopefully not auto-respond anymore.. that was only intended for Greptile and CI issues)
There was a problem hiding this comment.
Oh! I was looking at the wrong image which doesn't help..
It's quite odd but accurate - the image is a side by side of a map and globe view, so the jump is just the difference between these views
It might be interesting to have more general view comparison render tests - I think this is the first one that looks at this.
And maybe it'd be clearer if the test drew a line down the middle and/or text.. slightly less "pure" of a render test since it'd use deck features to draw, but idk.. maybe it'd be worth it for clarity.
Wdyt?
f7aaa69 to
a10f2db
Compare
PathStyleExtension needs no code change for GlobeView, but that had never been
verified empirically. This adds the proof and documents the reasoning.
dashMode 'path' accumulates dash offsets on the CPU as vec3.dist of
layer.projectPosition(p, {autoOffset: false}), i.e. in the active projection's
common space (sphere XYZ, GLOBE_RADIUS 256, under GlobeViewport). The dash
shader converts them with `instanceDashOffsets * project.scale / dashWidthPixels`
and PathLayer measures segment lengths in the same common space, so both sides
agree in either projection and GlobeViewport.scale converts them to pixels
consistently with Web Mercator (px/km ratio globe/Mercator = 1.00000 at z10-z12).
projectRenderedPathPosition's Taylor branch is guarded by
`instanceof WebMercatorViewport && zoom >= 12`, and PathLayer invalidates
instanceDashOffsets when viewport.projectionMode changes, so the zoom-12
Globe->Mercator handoff is covered too.
Render: path-dash-billboard-map-z10 and path-dash-units-z12 are expanded with
expandViewMatrix(['map', 'globe']) via a small withGlobeVariant helper, keeping
their existing viewState so the map goldens are unchanged. The two new globe
goldens show the same rows, dash lengths, gaps and phase as their map twins
(z10: 16 px dash / 20 px gap in both). z14/z18 are above GlobeView's handoff
and stay map-only.
Observation while baselining: under the Chromium/SwiftShader render device the
whole GlobeView picture at z12 is ~4% magnified and shifted ~6 px relative to
GlobeViewport.project() (z10: ~1%). A ScatterplotLayer probe and a solid
PathLayer show the identical displacement, and a GLSL probe measures
SwiftShader sin/cos errors of 2.6e-5..4.1e-5 (|p| - 1 = 6.1e-5 for the unit
sphere position), which fully accounts for it. It is a property of the render
GPU's trig precision in project_globe_, common to every layer on GlobeView,
and not related to dashing; the globe goldens therefore carry it.
Unit: a GlobeViewport testCase asserts getDashOffsets(path) equals the
cumulative chord distance of GlobeViewport.projectPosition of the vertices,
differs from the Mercator distance, and matches the instanceDashOffsets total.
Docs: Limitations paragraph describing GlobeView support for dashMode 'path'.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…isely Replace the implementation-level paragraph under Limitations with a single remark: dashes render the same in GlobeView as in MapView for every dashMode and dashUnits, including across the zoom-12 hand-off to Web Mercator. It is an expectation, not a limitation, so it moves above the Limitations heading. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…by side Replace the separate -globe goldens with a single multi-view image per case: MapView on the left half and GlobeView on the right half, both at the same view state. Dashes that cross the seam line up only if size, gap and phase agree between the two projections, which is the actual behaviour under test. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…oldens The globe half of the side-by-side PathStyle goldens is magnified by a few percent and shifted by a few pixels relative to the map half. Document the cause in the helper: fp32 sin/cos in the globe vertex projection under SwiftShader displace the sphere surface by a constant amount, which perspective turns into a uniform scale. The CPU viewport math is exact, and the effect vanishes at the origin and for meter-offset geometry. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…tead of Remarks Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
5e7316e to
0657342
Compare
…10664) * test(render): render PathStyleExtension dash cases under GlobeView PathStyleExtension needs no code change for GlobeView, but that had never been verified empirically. This adds the proof and documents the reasoning. dashMode 'path' accumulates dash offsets on the CPU as vec3.dist of layer.projectPosition(p, {autoOffset: false}), i.e. in the active projection's common space (sphere XYZ, GLOBE_RADIUS 256, under GlobeViewport). The dash shader converts them with `instanceDashOffsets * project.scale / dashWidthPixels` and PathLayer measures segment lengths in the same common space, so both sides agree in either projection and GlobeViewport.scale converts them to pixels consistently with Web Mercator (px/km ratio globe/Mercator = 1.00000 at z10-z12). projectRenderedPathPosition's Taylor branch is guarded by `instanceof WebMercatorViewport && zoom >= 12`, and PathLayer invalidates instanceDashOffsets when viewport.projectionMode changes, so the zoom-12 Globe->Mercator handoff is covered too. Render: path-dash-billboard-map-z10 and path-dash-units-z12 are expanded with expandViewMatrix(['map', 'globe']) via a small withGlobeVariant helper, keeping their existing viewState so the map goldens are unchanged. The two new globe goldens show the same rows, dash lengths, gaps and phase as their map twins (z10: 16 px dash / 20 px gap in both). z14/z18 are above GlobeView's handoff and stay map-only. Observation while baselining: under the Chromium/SwiftShader render device the whole GlobeView picture at z12 is ~4% magnified and shifted ~6 px relative to GlobeViewport.project() (z10: ~1%). A ScatterplotLayer probe and a solid PathLayer show the identical displacement, and a GLSL probe measures SwiftShader sin/cos errors of 2.6e-5..4.1e-5 (|p| - 1 = 6.1e-5 for the unit sphere position), which fully accounts for it. It is a property of the render GPU's trig precision in project_globe_, common to every layer on GlobeView, and not related to dashing; the globe goldens therefore carry it. Unit: a GlobeViewport testCase asserts getDashOffsets(path) equals the cumulative chord distance of GlobeViewport.projectPosition of the vertices, differs from the Mercator distance, and matches the instanceDashOffsets total. Docs: Limitations paragraph describing GlobeView support for dashMode 'path'. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * docs(extensions): state PathStyleExtension GlobeView expectation concisely Replace the implementation-level paragraph under Limitations with a single remark: dashes render the same in GlobeView as in MapView for every dashMode and dashUnits, including across the zoom-12 hand-off to Web Mercator. It is an expectation, not a limitation, so it moves above the Limitations heading. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * test(render): compare PathStyle dashes in MapView and GlobeView side by side Replace the separate -globe goldens with a single multi-view image per case: MapView on the left half and GlobeView on the right half, both at the same view state. Dashes that cross the seam line up only if size, gap and phase agree between the two projections, which is the actual behaviour under test. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * test(render): explain the GlobeView half offset in the map-vs-globe goldens The globe half of the side-by-side PathStyle goldens is magnified by a few percent and shifted by a few pixels relative to the map half. Document the cause in the helper: fp32 sin/cos in the globe vertex projection under SwiftShader displace the sphere surface by a constant amount, which perspective turns into a uniform scale. The CPU viewport math is exact, and the effect vanishes at the origin and for meter-offset geometry. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * docs(extensions): PathStyleExtension GlobeView note in what's new instead of Remarks Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * docs: narrow the PathStyleExtension GlobeView release note Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 * test(render): shorten the withGlobeSideBySide comment Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9 --------- Co-authored-by: Claude <[email protected]> (cherry picked from commit cad03c3)


Follow up of #10657
PathStyleExtensionneeds no change forGlobeView:dashMode: 'path'accumulates offsets in the active projection's common space,PathLayermeasures segments in the same space, andPathLayerinvalidatesinstanceDashOffsetswhenprojectionModechanges at the zoom-12 hand-off. This had not been verified. Tests and docs only.MapViewleft,GlobeViewrightpath-dash-billboard-map-z10-map-vs-globe: 8 px[4, 5]dashes withhighPrecisionDash, flat (red) and billboard (blue), dense and sparse paths, zoom 10path-dash-units-z12-map-vs-globe:dashMode: 'path'withdashUnits: 'widths'(top) and'pixels'(bottom), zoom 12No before images: both cases pass on master with this PR's spec, so the images show current behavior. Dash size, gap and phase continue across the centre seam.
Change List
path-dash.spec.ts:path-dash-billboard-map-z10andpath-dash-units-z12also render as one side-by-side image,MapViewon the left andGlobeViewon the right at the same view state (withGlobeSideBySide)path-dash-billboard-map-z10-map-vs-globe.pngandpath-dash-units-z12-map-vs-globe.png. The globe half is about 4% larger and a few pixels lower than the map half: SwiftShader's fp32sin/cosinproject_globe_displace the sphere surface by a constant amount, which perspective turns into a uniform scale. The CPU projection matches Mercator to 0.03 px. Documented on the helpergetDashOffsetsonGlobeViewportequals the cumulative sphere chord distance and matches theinstanceDashOffsetstotaldocs/whats-new.mdGlobeView compatibility bulletRan the render spec headless on WebGL, the unit spec,
tscand lint.Note
Low Risk
Documentation and test coverage only; no production code paths are modified.
Overview
Adds tests and release notes only—no runtime changes. The work documents and locks in that
PathStyleExtensionpath dashes already matchMapViewonGlobeView, because offsets and segment lengths use the active projection’s common space (sphere chords below the zoom‑12 handoff).Render suite:
path-dash.spec.tsintroduceswithGlobeSideBySide(MapView left, GlobeView right, same view state) plus helperscreateBillboardMapCaseandcreateDashUnitsCase. New golden casespath-dash-billboard-map-z10-map-vs-globeandpath-dash-units-z12-map-vs-globeassert dash size, gap, and phase stay continuous across the seam; globe half uses a slightly looser diff threshold for SwiftShader fp32 drift.Unit test: On a
GlobeViewport,getDashOffsetsmust equal cumulative chord distance in sphere common space, align withinstanceDashOffsets, and differ from Web Mercator distances.Docs:
whats-new.mdadds a GlobeView compatibility bullet forPathStyleExtensiondashes.Reviewed by Cursor Bugbot for commit 5e7316e. Bugbot is set up for automated code reviews on this repo. Configure here.