Skip to content

Commit

Permalink
fix raster tile flickering
Browse files Browse the repository at this point in the history
fixes #1270

Use the depth buffer to prevent double drawing in areas where raster
tiles overlap.
  • Loading branch information
ansis committed Jan 6, 2016
1 parent 83d7c67 commit a6604ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/render/draw_raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ var util = require('../util/util');
module.exports = drawRaster;

function drawRaster(painter, source, layer, coords) {
for (var i = 0; i < coords.length; i++) {
if (painter.isOpaquePass) return;

var gl = painter.gl;

// Change depth function to prevent double drawing in areas where tiles overlap.
gl.depthFunc(gl.LESS);

This comment has been minimized.

Copy link
@lucaswoj

lucaswoj Jan 6, 2016

Contributor

Brilliant. 👍


for (var i = coords.length - 1; i >= 0; i--) {
drawRasterTile(painter, source, layer, coords[i]);
}

gl.depthFunc(gl.LEQUAL);
}

function drawRasterTile(painter, source, layer, coord) {
if (painter.isOpaquePass) return;

painter.setDepthSublayer(0);

Expand Down

0 comments on commit a6604ab

Please sign in to comment.