diff options
author | 2019-11-05 20:40:17 +0100 | |
---|---|---|
committer | 2019-11-05 20:40:17 +0100 | |
commit | 5ff05b7f02b2ff1b0859a9a61ca7e1af6476424f (patch) | |
tree | d706d6085e7169e9e2ad38101f087aa8e592f256 /wgpu/src/shader/quad.vert | |
parent | db716b3bdf039b38fe7dcb17776cae7803d47d24 (diff) | |
download | iced-5ff05b7f02b2ff1b0859a9a61ca7e1af6476424f.tar.gz iced-5ff05b7f02b2ff1b0859a9a61ca7e1af6476424f.tar.bz2 iced-5ff05b7f02b2ff1b0859a9a61ca7e1af6476424f.zip |
Apply HiDPI scaling to quads
The anti-aliasing strategy is pretty naive, but we will manage for now.
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/shader/quad.vert | 20 | ||||
-rw-r--r-- | wgpu/src/shader/quad.vert.spv | bin | 2544 -> 3020 bytes |
2 files changed, 12 insertions, 8 deletions
diff --git a/wgpu/src/shader/quad.vert b/wgpu/src/shader/quad.vert index b7c5cf3e..539755cb 100644 --- a/wgpu/src/shader/quad.vert +++ b/wgpu/src/shader/quad.vert @@ -4,29 +4,33 @@ layout(location = 0) in vec2 v_Pos; layout(location = 1) in vec2 i_Pos; layout(location = 2) in vec2 i_Scale; layout(location = 3) in vec4 i_Color; -layout(location = 4) in uint i_BorderRadius; +layout(location = 4) in float i_BorderRadius; layout (set = 0, binding = 0) uniform Globals { mat4 u_Transform; + float u_Scale; }; layout(location = 0) out vec4 o_Color; layout(location = 1) out vec2 o_Pos; layout(location = 2) out vec2 o_Scale; -layout(location = 3) out uint o_BorderRadius; +layout(location = 3) out float o_BorderRadius; void main() { + vec2 p_Pos = i_Pos * u_Scale; + vec2 p_Scale = i_Scale * u_Scale; + mat4 i_Transform = mat4( - vec4(i_Scale.x, 0.0, 0.0, 0.0), - vec4(0.0, i_Scale.y, 0.0, 0.0), + 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(0.0, 0.0, 1.0, 0.0), - vec4(i_Pos, 0.0, 1.0) + vec4(p_Pos - vec2(0.5, 0.5), 0.0, 1.0) ); o_Color = i_Color; - o_Pos = i_Pos; - o_Scale = i_Scale; - o_BorderRadius = i_BorderRadius; + o_Pos = p_Pos; + o_Scale = p_Scale; + o_BorderRadius = i_BorderRadius * 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 Binary files differindex f62a160c..9050adfb 100644 --- a/wgpu/src/shader/quad.vert.spv +++ b/wgpu/src/shader/quad.vert.spv |