From cb6a1de41c636d1d1b915b4680aaf3ffb4bbe4be Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 13 Dec 2016 10:56:17 -0800 Subject: [PATCH] clearer pitched line antialiasing Project the extrusion and compare it's projected pixel length with the actual pixel length and adjust antialiasing accordingly. The previous approach calculated the adjustment much more indirectly and had no intuitive explanation. --- js/geo/transform.js | 10 ---------- js/render/draw_line.js | 5 ++--- package.json | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/js/geo/transform.js b/js/geo/transform.js index 49f8b0f428f..be59870a9e4 100644 --- a/js/geo/transform.js +++ b/js/geo/transform.js @@ -439,16 +439,6 @@ class Transform { if (!m) throw new Error("failed to invert matrix"); this.pixelMatrixInverse = m; - // line antialiasing matrix - m = mat2.create(); - mat2.scale(m, m, [1, Math.cos(this._pitch)]); - mat2.rotate(m, m, this.angle); - this.lineAntialiasingMatrix = m; - - // calculate how much longer the real world distance is at the top of the screen - // than at the middle of the screen. - const topEdgeLength = Math.sqrt((this.height * this.height + this.cameraToCenterDistance * this.cameraToCenterDistance) / 4); - this.lineStretch = (this.height / 2 * Math.tan(this._pitch)) / topEdgeLength; } } diff --git a/js/render/draw_line.js b/js/render/draw_line.js index a813750fd6e..c8599e7c3cc 100644 --- a/js/render/draw_line.js +++ b/js/render/draw_line.js @@ -80,6 +80,8 @@ function drawLineTile(program, painter, tile, buffers, layer, coord, layerData, gl.uniform2f(program.u_pattern_size_a, imagePosA.size[0] * image.fromScale / tileRatio, imagePosB.size[1]); gl.uniform2f(program.u_pattern_size_b, imagePosB.size[0] * image.toScale / tileRatio, imagePosB.size[1]); } + + gl.uniform2f(program.u_gl_units_to_pixels, 1 / painter.transform.pixelsToGLUnits[0], 1 / painter.transform.pixelsToGLUnits[1]); } if (programChanged) { @@ -105,9 +107,6 @@ function drawLineTile(program, painter, tile, buffers, layer, coord, layerData, gl.uniform1f(program.u_fade, image.t); } gl.uniform1f(program.u_width, layer.paint['line-width']); - - gl.uniformMatrix2fv(program.u_antialiasingmatrix, false, painter.transform.lineAntialiasingMatrix); - gl.uniform1f(program.u_extra, painter.transform.lineStretch); } painter.enableTileClippingMask(coord); diff --git a/package.json b/package.json index 7113874c9de..d92d077564f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "geojson-vt": "^2.4.0", "grid-index": "^1.0.0", "mapbox-gl-function": "mapbox/mapbox-gl-function#41c6724e2bbd7bd1eb5991451bbf118b7d02b525", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#69a834aa6b3c58e0ee60335590b443ac7742ed8d", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#a5401d074f2fb7a127f3fb4caff530ed2c6ad5a1", "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#e85407a377510acb647161de6be6357ab4f606dd", "mapbox-gl-supported": "^1.2.0", "package-json-versionify": "^1.0.2",