Skip to content

Commit

Permalink
fix tiny rendering differences caused by altitude
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Mar 4, 2015
1 parent e5ee155 commit 9d3efcd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,14 @@ Transform.prototype = {
getProjMatrix: function() {
var m = new Float64Array(16);
mat4.perspective(m, 2 * Math.atan((this.height / 2) / this.altitude), this.width / this.height, 0, this.altitude + 1);
mat4.translate(m, m, [0, 0, -this.altitude]);

// Subtracting by one z pixel here is weird. I'm not sure exactly what is going on,
// but this fixes tiny rendering differences between top-down (pitch=0) images rendered
// rendered with different altitude values. Without this, images with smaller altitude appear
// a tiny bit more zoomed. The difference is almost imperceptible, but it affects rendering tests.
var onePixelZ = 1 / this.height;

mat4.translate(m, m, [0, 0, -this.altitude - onePixelZ]);

// After the rotateX, z values are in pixel units. Convert them to
// altitude unites. 1 altitude unit = the screen height.
Expand Down

0 comments on commit 9d3efcd

Please sign in to comment.