@@ -30,15 +30,9 @@ fn solid_vs_main(input: SolidVertexInput) -> SolidVertexOutput {
3030
3131 var pos : vec2 <f32 > = (input . pos + min (input . shadow_offset , vec2 <f32 >(0 .0 , 0 .0 )) - input . shadow_blur_radius ) * globals . scale ;
3232 var scale : vec2 <f32 > = (input . scale + vec2 <f32 >(abs (input . shadow_offset . x ), abs (input . shadow_offset . y )) + input . shadow_blur_radius * 2 .0 ) * globals . scale ;
33- var snap : vec2 <f32 > = vec2 <f32 >(0 .0 , 0 .0 );
3433
35- if input . scale . x == 1 .0 {
36- snap . x = round (pos . x ) - pos . x ;
37- }
38-
39- if input . scale . y == 1 .0 {
40- snap . y = round (pos . y ) - pos . y ;
41- }
34+ var pos_snap : vec2 <f32 > = vec2 <f32 >(round (pos . x + 0 .01 ) - pos . x , round (pos . y + 0 .01 ) - pos . y );
35+ var scale_snap : vec2 <f32 > = vec2 <f32 >(round (scale . x + 0 .01 ) - scale . x , round (scale . y + 0 .01 ) - scale . y );
4236
4337 var min_border_radius = min (input . scale . x , input . scale . y ) * 0 .5 ;
4438 var border_radius : vec4 <f32 > = vec4 <f32 >(
@@ -49,17 +43,17 @@ fn solid_vs_main(input: SolidVertexInput) -> SolidVertexOutput {
4943 );
5044
5145 var transform : mat4x4 <f32 > = mat4x4 <f32 >(
52- vec4 <f32 >(scale . x + 1 .0 , 0 .0 , 0 .0 , 0 .0 ),
53- vec4 <f32 >(0 .0 , scale . y + 1 .0 , 0 .0 , 0 .0 ),
46+ vec4 <f32 >(scale . x + scale_snap . x + 1 .0 , 0 .0 , 0 .0 , 0 .0 ),
47+ vec4 <f32 >(0 .0 , scale . y + scale_snap . y + 1 .0 , 0 .0 , 0 .0 ),
5448 vec4 <f32 >(0 .0 , 0 .0 , 1 .0 , 0 .0 ),
55- vec4 <f32 >(pos - vec2 <f32 >(0 .5 , 0 .5 ) + snap , 0 .0 , 1 .0 )
49+ vec4 <f32 >(pos + pos_snap - vec2 <f32 >(0 .5 , 0 .5 ), 0 .0 , 1 .0 )
5650 );
5751
5852 out . position = globals . transform * transform * vec4 <f32 >(vertex_position (input . vertex_index ), 0 .0 , 1 .0 );
5953 out . color = premultiply (input . color );
6054 out . border_color = premultiply (input . border_color );
61- out . pos = input . pos * globals . scale + snap ;
62- out . scale = input . scale * globals . scale ;
55+ out . pos = input . pos * globals . scale + pos_snap ;
56+ out . scale = input . scale * globals . scale + scale_snap ;
6357 out . border_radius = border_radius * globals . scale ;
6458 out . border_width = input . border_width * globals . scale ;
6559 out . shadow_color = premultiply (input . shadow_color );
0 commit comments