瀏覽代碼

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 年之前
父節點
當前提交
60ed49e6e2
共有 1 個文件被更改,包括 3 次插入0 次删除
  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