diff --git a/src/render/draw_custom.js b/src/render/draw_custom.js index 6b198f33ef6..03f74ebabde 100644 --- a/src/render/draw_custom.js +++ b/src/render/draw_custom.js @@ -46,7 +46,9 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty painter.setCustomLayerDefaults(); context.setStencilMode(StencilMode.disabled); - context.setDepthMode(DepthMode.disabled); + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); + context.setDepthMode(depthMode); implementation.render(context.gl, painter.transform.customLayerMatrix()); diff --git a/test/integration/render-tests/custom-layer-js/depth/expected.png b/test/integration/render-tests/custom-layer-js/depth/expected.png new file mode 100644 index 00000000000..7a3ed65b8a2 Binary files /dev/null and b/test/integration/render-tests/custom-layer-js/depth/expected.png differ diff --git a/test/integration/render-tests/custom-layer-js/depth/style.json b/test/integration/render-tests/custom-layer-js/depth/style.json new file mode 100644 index 00000000000..17bde5a735e --- /dev/null +++ b/test/integration/render-tests/custom-layer-js/depth/style.json @@ -0,0 +1,66 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "operations": [ + [ + "addCustomLayer", + "null-island", + "fill" + ] + ] + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ + -20, + -10 + ], + [ + -20, + 10 + ], + [ + 0, + 10 + ], + [ + 0, + -10 + ], + [ + -20, + -10 + ] + ] + ] + } + } + }, + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "rgba(0,255,0, 1)" + } + }, + { + "id": "fill", + "type": "fill", + "source": "geojson", + "paint": { + "fill-antialias": false, + "fill-color": "rgba(235, 235,235, 1)" + } + } + ] +}