Skip to content

Commit 7a783a0

Browse files
authored
fix drawing precision when using asym borders (#751)
2 parents b11e995 + 8f44f1f commit 7a783a0

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src/core/shaders/webgl/Border.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ export const Border: WebGlShaderType<BorderProps> = {
6666
vec2 edge = clamp(a_nodeCoords * 2.0 - vec2(1.0), -1.0, 1.0);
6767
v_edgeWidth = 1.0 / u_pixelRatio;
6868
69-
float borderTop = u_borderWidth.x;
70-
float borderRight = u_borderWidth.y;
71-
float borderBottom = u_borderWidth.z;
72-
float borderLeft = u_borderWidth.w;
69+
vec4 adjustedBorderWidth = u_borderWidth - 1.0 + clamp(u_borderWidth, -1.0, 1.0);
70+
71+
float borderTop = adjustedBorderWidth.x;
72+
float borderRight = adjustedBorderWidth.y;
73+
float borderBottom = adjustedBorderWidth.z;
74+
float borderLeft = adjustedBorderWidth.w;
7375
7476
v_outerBorderUv = vec2(0.0);
7577
v_innerBorderUv = vec2(0.0);

src/core/shaders/webgl/RoundedWithBorder.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ export const RoundedWithBorder: WebGlShaderType<RoundedWithBorderProps> = {
8383
v_outerSize = vec2(0.0);
8484
8585
if(v_borderZero == 0.0) {
86-
float borderTop = u_borderWidth.x;
87-
float borderRight = u_borderWidth.y;
88-
float borderBottom = u_borderWidth.z;
89-
float borderLeft = u_borderWidth.w;
86+
vec4 adjustedBorderWidth = u_borderWidth - 1.0 + clamp(u_borderWidth, -1.0, 1.0);
87+
88+
float borderTop = adjustedBorderWidth.x;
89+
float borderRight = adjustedBorderWidth.y;
90+
float borderBottom = adjustedBorderWidth.z;
91+
float borderLeft = adjustedBorderWidth.w;
9092
9193
v_outerBorderUv = vec2(0.0);
9294
v_innerBorderUv = vec2(0.0);

src/core/shaders/webgl/RoundedWithBorderAndShadow.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ export const RoundedWithBorderAndShadow: WebGlShaderType<RoundedWithBorderAndSha
9292
v_outerSize = vec2(0.0);
9393
9494
if(v_borderZero == 0.0) {
95-
float borderTop = u_borderWidth.x;
96-
float borderRight = u_borderWidth.y;
97-
float borderBottom = u_borderWidth.z;
98-
float borderLeft = u_borderWidth.w;
95+
vec4 adjustedBorderWidth = u_borderWidth - 1.0 + clamp(u_borderWidth, -1.0, 1.0);
96+
97+
float borderTop = adjustedBorderWidth.x;
98+
float borderRight = adjustedBorderWidth.y;
99+
float borderBottom = adjustedBorderWidth.z;
100+
float borderLeft = adjustedBorderWidth.w;
99101
100102
v_outerBorderUv = vec2(0.0);
101103
v_innerBorderUv = vec2(0.0);

0 commit comments

Comments
 (0)