Browse Source

Canvas2D enhance text rendering quality (#1199)

* Change text drawing starting location to the right place in case of multi-line

* Fix textSize null case

* Canvas2D: enhance text rendering quality
Loïc Baumann 9 years ago
parent
commit
60ed49e6e2
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/Shaders/text2d.vertex.fx

+ 3 - 0
src/Shaders/text2d.vertex.fx

@@ -49,6 +49,9 @@ void main(void) {
 		vUV = vec2(topLeftUV.x + sizeUV.x, topLeftUV.y + sizeUV.y);
 	}
 
+	// Align texture coordinate to texel to enhance rendering quality
+	vUV = (floor(vUV*textureSize) + vec2(0.0, 0.0)) / textureSize;
+
 	vColor = color;
 	vec4 pos;
 	pos.xy = floor(pos2.xy * sizeUV * textureSize);	// Align on target pixel to avoid bad interpolation