Sfoglia il codice sorgente

tentative fix at pixel alignment issues

Nicolas Cannasse 11 anni fa
parent
commit
9ce94cd038
3 ha cambiato i file con 8 aggiunte e 4 eliminazioni
  1. 2 3
      h2d/Drawable.hx
  2. 5 0
      h2d/Scene.hx
  3. 1 1
      h2d/Tile.hx

+ 2 - 3
h2d/Drawable.hx

@@ -417,9 +417,8 @@ class Drawable extends Sprite {
 
 		if( options & HAS_SIZE != 0 ) {
 			var tmp = core.tmpSize;
-			// adds 1/10 pixel size to prevent precision loss after scaling
-			tmp.x = tile.width + 0.1;
-			tmp.y = tile.height + 0.1;
+			tmp.x = tile.width;
+			tmp.y = tile.height;
 			tmp.z = 1;
 			shader.size = tmp;
 		}

+ 5 - 0
h2d/Scene.hx

@@ -358,6 +358,11 @@ class Scene extends Layers implements h3d.IDrawable {
 		var h = -2 / height;
 		absX = absX * w - 1;
 		absY = absY * h + 1;
+		
+		// half pixel align
+		absX += 1 / width;
+		absY -= 1 / height;
+		
 		matA *= w;
 		matB *= h;
 		matC *= w;

+ 1 - 1
h2d/Tile.hx

@@ -3,7 +3,7 @@ package h2d;
 @:allow(h2d)
 class Tile {
 	
-	static inline var EPSILON_PIXEL = 0.001;
+	static inline var EPSILON_PIXEL = 0;
 	
 	var innerTex : h3d.mat.Texture;