Skip to content

Commit a725eca

Browse files
fix: line-layer-opacity clipping subsequent same-source layers (#7867)
* test: add regression test for line-layer-opacity clipping a subsequent same-source layer (#7865) Adds a render test reproducing #7865: a shared GeoJSON source with three filtered line layers where the middle layer uses line-layer-opacity. The subsequent same-source layer disappears because the layer-opacity path re-renders tile clipping masks into the scratch FBO and leaves currentStencilSource pointing at the source, so the next layer is clipped by stale stencil state. expected.png is blessed here against the current (buggy) rendering — the blue line is missing. The follow-up commit enables the fix and re-blesses, so the restored line shows up as an image diff in this PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: reset stencil-source after line/fill-layer-opacity composite (#7865) Reset painter.currentStencilSource after compositing a layer-opacity layer so a subsequent layer sharing the same source redraws its tile clipping masks into the composite target instead of being clipped by stale stencil state. Covers both line-layer-opacity and fill-layer-opacity. Re-blesses the render test: the previously-missing line is now rendered. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f2bf791 commit a725eca

4 files changed

Lines changed: 86 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- _...Add new stuff here..._
55

66
### 🐞 Bug fixes
7+
- Fix `line-layer-opacity`/`fill-layer-opacity` clipping away a subsequent layer that shares the same source ([#7867](https://github.com/maplibre/maplibre-gl-js/pull/7867)) (by [@CommanderStorm](https://github.com/CommanderStorm))
78
- Fix camera jump in flyTo when minZoom is set ([#7743](https://github.com/maplibre/maplibre-gl-js/pull/7743)) (by [@YuChunTsao](https://github.com/YuChunTsao))
89
- _...Add new stuff here..._
910

src/webgl/draw/draw_layer_opacity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,8 @@ export function drawLayerOpacity(painter: Painter, opacity: number, prepareDrawL
8787
layerOpacityUniformValues(opacity, 0), null, null,
8888
layer.id, painter.viewportBuffer, painter.quadTriangleIndexBuffer,
8989
painter.viewportSegments, layer.paint, painter.transform.zoom);
90+
91+
// Clipping masks were drawn into the scratch FBO's stencil buffer, not the composite target's.
92+
// Reset currentStencilSource so a later layer on the same source redraws its masks into the composite target instead of reusing stale ones.
93+
painter.currentStencilSource = undefined;
9094
}
1.29 KB
Loading
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"width": 64,
6+
"height": 64
7+
}
8+
},
9+
"sources": {
10+
"geojson": {
11+
"type": "geojson",
12+
"data": {
13+
"type": "FeatureCollection",
14+
"features": [
15+
{
16+
"type": "Feature",
17+
"properties": { "id": "red" },
18+
"geometry": {
19+
"type": "LineString",
20+
"coordinates": [[-15, -15], [15, 15]]
21+
}
22+
},
23+
{
24+
"type": "Feature",
25+
"properties": { "id": "green" },
26+
"geometry": {
27+
"type": "LineString",
28+
"coordinates": [[15, -15], [-15, 15]]
29+
}
30+
},
31+
{
32+
"type": "Feature",
33+
"properties": { "id": "blue" },
34+
"geometry": {
35+
"type": "LineString",
36+
"coordinates": [[-15, 0], [15, 0]]
37+
}
38+
}
39+
]
40+
}
41+
}
42+
},
43+
"layers": [
44+
{
45+
"id": "background",
46+
"type": "background",
47+
"paint": { "background-color": "white" }
48+
},
49+
{
50+
"id": "line-red",
51+
"type": "line",
52+
"source": "geojson",
53+
"filter": ["==", ["get", "id"], "red"],
54+
"paint": {
55+
"line-width": 12,
56+
"line-color": "#ff0000"
57+
}
58+
},
59+
{
60+
"id": "line-green",
61+
"type": "line",
62+
"source": "geojson",
63+
"filter": ["==", ["get", "id"], "green"],
64+
"paint": {
65+
"line-width": 12,
66+
"line-color": "#00ff00",
67+
"line-layer-opacity": 0.5
68+
}
69+
},
70+
{
71+
"id": "line-blue",
72+
"type": "line",
73+
"source": "geojson",
74+
"filter": ["==", ["get", "id"], "blue"],
75+
"paint": {
76+
"line-width": 12,
77+
"line-color": "#0000ff"
78+
}
79+
}
80+
]
81+
}

0 commit comments

Comments
 (0)