OSDN Git Service

Adjust UVs differently to avoid FP rounding errors.
authorNathanSweet <nathan.sweet@gmail.com>
Thu, 10 Oct 2013 10:17:08 +0000 (12:17 +0200)
committerNathanSweet <nathan.sweet@gmail.com>
Thu, 10 Oct 2013 10:17:08 +0000 (12:17 +0200)
Some 1x1 pixel regions on a 1024x1024 atlas weren't rendering.

gdx/src/com/badlogic/gdx/graphics/g2d/TextureRegion.java

index 6777bd9..ff3fd78 100644 (file)
@@ -91,12 +91,14 @@ public class TextureRegion {
                regionWidth = Math.round(Math.abs(u2 - u) * texWidth);\r
                regionHeight = Math.round(Math.abs(v2 - v) * texHeight);\r
 \r
-               // For a 1x1 region, adjust UVs to pixel center to avoid filtering artifacts on AMD GPUs when drawing stretched.\r
+               // For a 1x1 region, adjust UVs toward pixel center to avoid filtering artifacts on AMD GPUs when drawing very stretched.\r
                if (regionWidth == 1 && regionHeight == 1) {\r
-                       u += 0.5f / texWidth;\r
-                       u2 = u;\r
-                       v += 0.5f / texHeight;\r
-                       v2 = v;\r
+                       float adjustX = 0.25f / texWidth;\r
+                       u += adjustX;\r
+                       u2 -= adjustX;\r
+                       float adjustY = 0.25f / texHeight;\r
+                       v += adjustY;\r
+                       v2 -= adjustY;\r
                }\r
 \r
                this.u = u;\r