Skip to content

Add color releif and terrain tests from maplibre-native - #8388

Merged
HarelM merged 4 commits into
maplibre:mainfrom
WifiDB:terrain-oracles
Sep 9, 2026
Merged

Add color releif and terrain tests from maplibre-native#8388
HarelM merged 4 commits into
maplibre:mainfrom
WifiDB:terrain-oracles

Conversation

@acalcutt

@acalcutt acalcutt commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This PR brings over tests created for maplibre-native color relief, terrain occlusion, and fill extrusion to maplibre-gl-js so we can have a good baseline for the maplibre-native terrain PR maplibre/maplibre-native#4190

These tests use assets from my own generated JAXA terrain, GEBCO bathymetry, and OSM land vector tiles.

Tests Added

Assisted-By: Claude AI was used in generating the tests and migrating them for this PR. (the PR text is my own)

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes. (included as expect images)
  • Write tests for all new functionality.
  • [] Document any changes to public APIs.
  • If you changed code in a file that has a benchmark file next to it (*.bench.ts), post before/after results of npm run bench (the compare workflow is in test/bench/README.md).
  • Add an entry to CHANGELOG.md under the ## main section.
  • Confirm you have read our AI policy here.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.39%. Comparing base (f985318) to head (4a04352).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8388   +/-   ##
=======================================
  Coverage   94.38%   94.39%           
=======================================
  Files         298      298           
  Lines       25737    25737           
  Branches     6821     6821           
=======================================
+ Hits        24293    24294    +1     
+ Misses       1444     1443    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread test/integration/assets/tiles/README.md Outdated
@@ -0,0 +1,8 @@
## Attribution

Fixtures added for the color-relief render tests. Other files in this folder

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.

Either add the other files as well or remove this file entirely, I would like to avoid a semi-correct file...

"test": {
"height": 512,
"width": 512,
"description": "Fill-extrusion over 3D terrain: buildings must sit ON the terrain surface (raised by the DEM elevation at their centroid), not at sea level. Rendered at a pitch over sloping ground so a building drawn without elevation sinks into / floats over the hillside instead of resting on it. Buildings are inline GeoJSON so the test needs no extra tile fixtures beyond the terrain DEM."

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.

This is describing what it shouldn't do instead of focusing what the test is showing, please trim this comment a bit.

Comment thread test/integration/render/tests/terrain/occlusion-debug/style.json Outdated
@HarelM

HarelM commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Cool thanks! Added some minor comments but otherwise looks good.

@HarelM

HarelM commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Ping me when you need another round of review.

acalcutt and others added 4 commits September 9, 2026 08:51
…errain branch

These two styles exist as render tests on maplibre-native's feature/terrain-3d
branch but have no GL JS counterpart, so native has been validating them against
baselines captured from its own output. Bringing them here gives both engines the
same styles and makes GL JS the oracle.

Both run on fixtures already present: the terrain-shading DEM tiles at
12-2178-1434, 12-2178-1435, 12-2179-1434 and 12-2179-1435, and number/{z}.png.
No new assets.

- terrain/fill-extrusion: extrusions over terrain, checking they sit on the
  surface rather than at sea level, at pitch 45 with exaggeration 0.45.
- terrain/occlusion-debug: symbols behind terrain, for label occlusion.

Baselines generated with UPDATE=true. As a check on the harness, the same run
regenerated all 84 existing terrain baselines byte-identically, so these two are
produced the same way as the rest of the suite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…sion

As first ported, terrain/occlusion-debug used exaggeration 0.45. The relief was
gentle enough that nothing stood between the camera and the labels, so all 25
rendered and the test would have passed just as happily with occlusion disabled.

Raising the exaggeration to 3 puts ridges in front of most of the grid: eight
labels survive and seventeen are hidden. text-allow-overlap and
text-ignore-placement were already set, so collision cannot hide any of them and
occlusion is the only thing that can.

Checked that the missing labels are occluded rather than off screen by rendering
the same camera and labels with the terrain flattened (exaggeration ~0), which
shows all 25. So a regression in occlusion brings seventeen labels back and moves
a large fraction of the frame.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
maplibre-native has a `color-relief/low-zoom` case this suite has no
equivalent of. The four color-relief tests here are byte-identical to
native's, but all sit at zoom 11, so nothing covers the exaggeration
scaling applied at low zoom; native wrote this one for a zoom-0 relief
intensity bug.

Ported unchanged, including its DEM source. It needs four z1 tiles: the
DEM fixtures here are four z12 tiles over the Grand Canyon, which cannot
render a zoom-1 view of Europe. They are JAXA AW3D30, attributed in the
folder README, and byte-identical to the copy maplibre-native uses, so the
two engines can be compared on the same DEM.

The tiles are WebP, which is new for this suite but renders bit-identically
to the same data as PNG - Chrome decodes both to the same RGBA, verified,
and the test output is unchanged to 0.000% of pixels. `.gitattributes`
gains `*.webp binary`: it sets `* text eol=lf` and lists the other binary
formats, so without it git line-ending-normalises the tiles and corrupts
them. A DEM carries elevation in the low bits, so that is silent damage
rather than a visibly broken image.

`.cspell.json` gains `JAXA`. The word list already covers names like it, and
the attribution reads `[AW3D30 (JAXA)](...)`, which the `\[\w+` ignore pattern
does not cover: that only skips a word sitting directly against the bracket,
as in `[GEBCO](...)`.

The two engines agree closely on the test - mean absolute channel
difference 1.55, with 0.08% of pixels differing by more than 128 - so it
lands as something both implementations already satisfy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…tive

Three tests this suite has no equivalent of. `combinations/` has 123 entries
and none of them involve color-relief, so nothing here covers what happens
when color-relief composites against something other than the background:

- `color-relief--hillshade--vector-fill--color-relief--hillshade` puts a
  vector fill between two relief pairs, so the upper color-relief has to
  draw over vector geometry.
- `color-relief--hillshade--color-relief--hillshade` is the same without the
  fill, to isolate it.
- `color-relief-translucent--hillshade-translucent-low-zoom` stacks two
  translucent relief layers at zoom 1.

Native wrote the first two against a backend-specific regression, where
color-relief above a vector layer rendered on one backend and not another.
That motivation does not carry over, but the layer ordering they check is
engine-independent, and this suite is the reference the native one is
compared against.

The land DEM points at the JAXA tiles added with the low-zoom test rather
than at new fixtures: native's copies read a second, older build of the same
data under a different URL template, and both sides now read the one set.
The styles are byte-identical between the two repos.

Adds six fixtures, each dataset in its own folder with a README covering
that folder: `gebco/` for the bathymetry DEM and `osm/` for the vector
basemap, alongside the `jaxa/` land DEM. They are three datasets under
three licences and two of them sit side by side in these styles, so a
folder each keeps the attribution unambiguous. Only z1 is needed for a
zoom-1 view, so this is 2.9 MB rather than the 7.2 MB the full fixture set
would have cost.

The two engines agree closely: mean absolute channel difference 1.5 to 2.5,
with under 3.3% of pixels differing by more than 32.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@acalcutt

acalcutt commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@HarelM I think this should be ready for re-review

osm pbf files were moved to their own folder so the attribution could be just for those files. Test descriptions have been updated

@HarelM
HarelM merged commit 48eb1e4 into maplibre:main Sep 9, 2026
25 checks passed
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.

2 participants