소스 검색

Merge pull request #1939 from nockawa/fontCharAlignBug

Canvas2D: improve render rendering, again...
Loïc Baumann 8 년 전
부모
커밋
fb760ce9a1

+ 2 - 2
canvas2D/src/Engine/babylon.text2d.ts

@@ -802,7 +802,7 @@
                         if(char !== "\t" && !this._isWhiteSpaceCharVert(char)){ 
                             //make sure space char gets processed here or overlapping can occur when text is set
                             let ci = texture.getChar(char);
-                            let partOffset = new Vector2(offset.x + ci.xOffset, offset.y + ci.yOffset);
+                            let partOffset = new Vector2(Math.floor(offset.x + ci.xOffset), Math.floor(offset.y + ci.yOffset));
                             this.updateInstanceDataPart(d, partOffset);
                             d.topLeftUV = ci.topLeftUV;
                             let suv = ci.bottomRightUV.subtract(ci.topLeftUV);
@@ -816,7 +816,7 @@
                             ++d.curElement;
                         }
 
-                        offset.x += charWidth;
+                        offset.x += Math.floor(charWidth);
                         charNum++;
                     }
 

+ 2 - 2
canvas2D/src/shaders/text2d.vertex.fx

@@ -71,8 +71,8 @@ void main(void) {
 		float irw = 2.0 / rw;
 		float irh = 2.0 / rh;
 
-		x = (floor((x / irw)) * irw) + irw / 2.0;
-		y = (floor((y / irh)) * irh) + irh / 2.0;
+		x = ((floor((x / irw) + 0.5) * irw) + irw / 2.0) + 0.5*irw;
+		y = ((floor((y / irh) + 0.5) * irh) + irh / 2.0) + 0.5*irh;
 	}
 
 	gl_Position = vec4(x, y, zBias.x, 1.0);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3 - 3
dist/preview release/canvas2D/babylon.canvas2d.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 7 - 7
dist/preview release/canvas2D/babylon.canvas2d.min.js