Skip to content

Commit

Permalink
Fix symbol rendering under opaque fill layers (mapbox#7612)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhamley authored and pirxpilot committed Jun 18, 2019
1 parent 377b5e2 commit b693a69
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/render/draw_symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ function drawLayerSymbols(painter, sourceCache, layer, coords, isText, translate
// Unpitched point labels need to have their rotation applied after projection
const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;

const depthOn = pitchWithMap;

const depthMode = depthOn ? painter.depthModeForSublayer(0, DepthMode.ReadOnly) : DepthMode.disabled;
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);

let program;
let size;
Expand Down
5 changes: 2 additions & 3 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ class Painter {
}

depthModeForSublayer(n, mask, func) {
const farDepth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon;
const nearDepth = farDepth - 1 + this.depthRange;
return new DepthMode(func || this.context.gl.LEQUAL, mask, [nearDepth, farDepth]);
const depth = 1 - ((1 + this.currentLayer) * this.numSublayers + n) * this.depthEpsilon;
return new DepthMode(func || this.context.gl.LEQUAL, mask, [depth, depth]);
}

render(style, options) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64
}
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "Polygon",
"coordinates": [
[
[
-20,
-20
],
[
-20,
20
],
[
20,
20
],
[
20,
-20
],
[
-20,
-20
]
]
]
}
},
"icon-source": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
},
"properties": {
"icon": "building"
}
}
]
}
}
},
"sprite": "local://sprites/sprite",
"layers": [
{
"id": "icons",
"type": "symbol",
"source": "icon-source",
"layout": {
"icon-image": "{icon}-12"
}
},
{
"id": "fill",
"type": "fill",
"source": "geojson"
}
]
}

0 comments on commit b693a69

Please sign in to comment.