fix z-fighting on overlapping buildings:

- modify projection matrix to add offset, glPolygonOffset is not that reliable
This commit is contained in:
Hannes Janetzek
2013-01-11 22:27:16 +01:00
parent d1388660a1
commit 007ab2e3bf
2 changed files with 29 additions and 16 deletions

View File

@@ -230,4 +230,15 @@ public class GlUtils {
matrix[5] = sy;
matrix[10] = sz;
}
public static void addOffsetM(float[] matrix, int delta) {
// from http://www.mathfor3dgameprogramming.com/code/Listing9.1.cpp
// float n = MapViewPosition.VIEW_NEAR;
// float f = MapViewPosition.VIEW_FAR;
// float pz = 1;
// float epsilon = -2.0f * f * n * delta / ((f + n) * pz * (pz + delta));
float epsilon = 1.0f / (1 << 11);
matrix[10] *= 1.0f + epsilon * delta;
}
}