From fbe3aa3cf4898bf2c2c3858d10d62285b0dbae9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 27 May 2020 00:23:42 +0200 Subject: [PATCH] Align quads to physical pixels in `iced_wgpu` --- wgpu/src/shader/quad.vert | 12 ++++++------ wgpu/src/shader/quad.vert.spv | Bin 3372 -> 3348 bytes 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wgpu/src/shader/quad.vert b/wgpu/src/shader/quad.vert index 1d9a4fd2..11f95eeb 100644 --- a/wgpu/src/shader/quad.vert +++ b/wgpu/src/shader/quad.vert @@ -21,14 +21,14 @@ layout(location = 4) out float o_BorderRadius; layout(location = 5) out float o_BorderWidth; void main() { - vec2 p_Pos = i_Pos * u_Scale; - vec2 p_Scale = i_Scale * u_Scale; + vec2 p_Pos = floor(i_Pos * u_Scale); + vec2 p_Scale = floor(i_Scale * u_Scale); mat4 i_Transform = mat4( - vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0), - vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0), + vec4(p_Scale.x, 0.0, 0.0, 0.0), + vec4(0.0, p_Scale.y, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), - vec4(p_Pos - vec2(0.5, 0.5), 0.0, 1.0) + vec4(p_Pos, 0.0, 1.0) ); o_Color = i_Color; @@ -36,7 +36,7 @@ void main() { o_Pos = p_Pos; o_Scale = p_Scale; o_BorderRadius = i_BorderRadius * u_Scale; - o_BorderWidth = i_BorderWidth * u_Scale; + o_BorderWidth = floor(i_BorderWidth * u_Scale); gl_Position = u_Transform * i_Transform * vec4(v_Pos, 0.0, 1.0); } diff --git a/wgpu/src/shader/quad.vert.spv b/wgpu/src/shader/quad.vert.spv index 7059b51bc4575638f541d299aa07e0a12e4f6599..b3025a93396f709bb29e9cee5ab8779873115751 100644 GIT binary patch literal 3348 zcmZXVU2{}L5QY!=*nl92$cKt?Lr_#8q5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