From 9ab7c47dc7d834ee73bc068f9f34eea4d6946436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 31 Dec 2019 21:35:42 +0100 Subject: [PATCH] Add `border_width` and `border_color` to `Quad` --- core/src/color.rs | 8 ++++ examples/custom_widget.rs | 2 + examples/tour.rs | 2 +- wgpu/src/primitive.rs | 4 ++ wgpu/src/quad.rs | 17 +++++++- wgpu/src/renderer.rs | 9 +++- wgpu/src/renderer/widget/button.rs | 8 +++- wgpu/src/renderer/widget/checkbox.rs | 44 ++++++++----------- wgpu/src/renderer/widget/container.rs | 4 +- wgpu/src/renderer/widget/radio.rs | 46 ++++++++------------ wgpu/src/renderer/widget/scrollable.rs | 8 +++- wgpu/src/renderer/widget/slider.rs | 58 +++++++++++-------------- wgpu/src/renderer/widget/text_input.rs | 33 +++++--------- wgpu/src/shader/quad.frag | 51 ++++++++++++++++++---- wgpu/src/shader/quad.frag.spv | Bin 3044 -> 4212 bytes wgpu/src/shader/quad.vert | 14 ++++-- wgpu/src/shader/quad.vert.spv | Bin 3020 -> 3372 bytes 17 files changed, 180 insertions(+), 128 deletions(-) diff --git a/core/src/color.rs b/core/src/color.rs index c28e784f..d72651d9 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -25,6 +25,14 @@ impl Color { a: 1.0, }; + /// A color with no opacity. + pub const TRANSPARENT: Color = Color { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0.0, + }; + /// Creates a [`Color`] from its RGB8 components. /// /// [`Color`]: struct.Color.html diff --git a/examples/custom_widget.rs b/examples/custom_widget.rs index ca562ead..1f51ee54 100644 --- a/examples/custom_widget.rs +++ b/examples/custom_widget.rs @@ -63,6 +63,8 @@ mod circle { bounds: layout.bounds(), background: Background::Color(Color::BLACK), border_radius: self.radius, + border_width: 0, + border_color: Color::TRANSPARENT, }, MouseCursor::OutOfBounds, ) diff --git a/examples/tour.rs b/examples/tour.rs index c7f866e8..d006d397 100644 --- a/examples/tour.rs +++ b/examples/tour.rs @@ -27,7 +27,7 @@ impl Sandbox for Tour { scroll: scrollable::State::new(), back_button: button::State::new(), next_button: button::State::new(), - debug: false, + debug: true, } } diff --git a/wgpu/src/primitive.rs b/wgpu/src/primitive.rs index 6c61f800..f4609151 100644 --- a/wgpu/src/primitive.rs +++ b/wgpu/src/primitive.rs @@ -38,6 +38,10 @@ pub enum Primitive { background: Background, /// The border radius of the quad border_radius: u16, + /// The border width of the quad + border_width: u16, + /// The border color of the quad + border_color: Color, }, /// An image primitive Image { diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index c292dec3..fe3276a3 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -125,9 +125,19 @@ impl Pipeline { }, wgpu::VertexAttributeDescriptor { shader_location: 4, - format: wgpu::VertexFormat::Float, + format: wgpu::VertexFormat::Float4, offset: 4 * (2 + 2 + 4), }, + wgpu::VertexAttributeDescriptor { + shader_location: 5, + format: wgpu::VertexFormat::Float, + offset: 4 * (2 + 2 + 4 + 4), + }, + wgpu::VertexAttributeDescriptor { + shader_location: 6, + format: wgpu::VertexFormat::Float, + offset: 4 * (2 + 2 + 4 + 4 + 1), + }, ], }, ], @@ -233,7 +243,8 @@ impl Pipeline { bounds.x, bounds.y, bounds.width, - bounds.height, + // TODO: Address anti-aliasing adjustments properly + bounds.height + 1, ); render_pass.draw_indexed( @@ -277,7 +288,9 @@ pub struct Quad { pub position: [f32; 2], pub scale: [f32; 2], pub color: [f32; 4], + pub border_color: [f32; 4], pub border_radius: f32, + pub border_width: f32, } impl Quad { diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 1b143d90..efda046b 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -223,6 +223,8 @@ impl Renderer { bounds, background, border_radius, + border_width, + border_color, } => { // TODO: Move some of this computations to the GPU (?) layer.quads.push(Quad { @@ -235,6 +237,8 @@ impl Renderer { Background::Color(color) => color.into_linear(), }, border_radius: *border_radius as f32, + border_width: *border_width as f32, + border_color: border_color.into_linear(), }); } Primitive::Image { handle, bounds } => { @@ -470,11 +474,12 @@ fn explain_layout( color: Color, primitives: &mut Vec, ) { - // TODO: Draw borders instead primitives.push(Primitive::Quad { bounds: layout.bounds(), - background: Background::Color([0.0, 0.0, 0.0, 0.05].into()), + background: Background::Color(Color::TRANSPARENT), border_radius: 0, + border_width: 1, + border_color: [0.6, 0.6, 0.6, 0.5].into(), }); for child in layout.children() { diff --git a/wgpu/src/renderer/widget/button.rs b/wgpu/src/renderer/widget/button.rs index 4fbd90d7..d00a43a5 100644 --- a/wgpu/src/renderer/widget/button.rs +++ b/wgpu/src/renderer/widget/button.rs @@ -1,5 +1,7 @@ use crate::{button::StyleSheet, defaults, Defaults, Primitive, Renderer}; -use iced_native::{Background, Element, Layout, MouseCursor, Point, Rectangle}; +use iced_native::{ + Background, Color, Element, Layout, MouseCursor, Point, Rectangle, +}; impl iced_native::button::Renderer for Renderer { type Style = Box; @@ -57,11 +59,15 @@ impl iced_native::button::Renderer for Renderer { [0.0, 0.0, 0.0, 0.5].into(), ), border_radius: styling.border_radius, + border_width: 0, + border_color: Color::TRANSPARENT, }, Primitive::Quad { bounds, background, border_radius: styling.border_radius, + border_width: 0, + border_color: Color::TRANSPARENT, }, content, ], diff --git a/wgpu/src/renderer/widget/checkbox.rs b/wgpu/src/renderer/widget/checkbox.rs index 54b4b1cc..1ed27ff7 100644 --- a/wgpu/src/renderer/widget/checkbox.rs +++ b/wgpu/src/renderer/widget/checkbox.rs @@ -1,6 +1,6 @@ use crate::{Primitive, Renderer}; use iced_native::{ - checkbox, Background, HorizontalAlignment, MouseCursor, Rectangle, + checkbox, Background, Color, HorizontalAlignment, MouseCursor, Rectangle, VerticalAlignment, }; @@ -18,30 +18,20 @@ impl checkbox::Renderer for Renderer { is_mouse_over: bool, (label, _): Self::Output, ) -> Self::Output { - let (checkbox_border, checkbox_box) = ( - Primitive::Quad { - bounds, - background: Background::Color([0.6, 0.6, 0.6].into()), - border_radius: 6, - }, - Primitive::Quad { - bounds: Rectangle { - x: bounds.x + 1.0, - y: bounds.y + 1.0, - width: bounds.width - 2.0, - height: bounds.height - 2.0, - }, - background: Background::Color( - if is_mouse_over { - [0.90, 0.90, 0.90] - } else { - [0.95, 0.95, 0.95] - } - .into(), - ), - border_radius: 5, - }, - ); + let checkbox = Primitive::Quad { + bounds, + background: Background::Color( + if is_mouse_over { + [0.90, 0.90, 0.90] + } else { + [0.95, 0.95, 0.95] + } + .into(), + ), + border_radius: 5, + border_width: 1, + border_color: Color::from_rgb(0.6, 0.6, 0.6), + }; ( Primitive::Group { @@ -56,9 +46,9 @@ impl checkbox::Renderer for Renderer { vertical_alignment: VerticalAlignment::Center, }; - vec![checkbox_border, checkbox_box, check, label] + vec![checkbox, check, label] } else { - vec![checkbox_border, checkbox_box, label] + vec![checkbox, label] }, }, if is_mouse_over { diff --git a/wgpu/src/renderer/widget/container.rs b/wgpu/src/renderer/widget/container.rs index 29c709f8..18908571 100644 --- a/wgpu/src/renderer/widget/container.rs +++ b/wgpu/src/renderer/widget/container.rs @@ -1,5 +1,5 @@ use crate::{container, defaults, Defaults, Primitive, Renderer}; -use iced_native::{Element, Layout, Point, Rectangle}; +use iced_native::{Color, Element, Layout, Point, Rectangle}; impl iced_native::container::Renderer for Renderer { type Style = Box; @@ -31,6 +31,8 @@ impl iced_native::container::Renderer for Renderer { bounds, background, border_radius: style.border_radius, + border_width: 0, + border_color: Color::TRANSPARENT, }; ( diff --git a/wgpu/src/renderer/widget/radio.rs b/wgpu/src/renderer/widget/radio.rs index 3c00a4c2..aa1dbadc 100644 --- a/wgpu/src/renderer/widget/radio.rs +++ b/wgpu/src/renderer/widget/radio.rs @@ -1,5 +1,5 @@ use crate::{Primitive, Renderer}; -use iced_native::{radio, Background, MouseCursor, Rectangle}; +use iced_native::{radio, Background, Color, MouseCursor, Rectangle}; const SIZE: f32 = 28.0; const DOT_SIZE: f32 = SIZE / 2.0; @@ -16,30 +16,20 @@ impl radio::Renderer for Renderer { is_mouse_over: bool, (label, _): Self::Output, ) -> Self::Output { - let (radio_border, radio_box) = ( - Primitive::Quad { - bounds, - background: Background::Color([0.6, 0.6, 0.6].into()), - border_radius: (SIZE / 2.0) as u16, - }, - Primitive::Quad { - bounds: Rectangle { - x: bounds.x + 1.0, - y: bounds.y + 1.0, - width: bounds.width - 2.0, - height: bounds.height - 2.0, - }, - background: Background::Color( - if is_mouse_over { - [0.90, 0.90, 0.90] - } else { - [0.95, 0.95, 0.95] - } - .into(), - ), - border_radius: (SIZE / 2.0 - 1.0) as u16, - }, - ); + let radio = Primitive::Quad { + bounds, + background: Background::Color( + if is_mouse_over { + [0.90, 0.90, 0.90] + } else { + [0.95, 0.95, 0.95] + } + .into(), + ), + border_radius: (SIZE / 2.0) as u16, + border_width: 1, + border_color: Color::from_rgb(0.6, 0.6, 0.6), + }; ( Primitive::Group { @@ -53,11 +43,13 @@ impl radio::Renderer for Renderer { }, background: Background::Color([0.3, 0.3, 0.3].into()), border_radius: (DOT_SIZE / 2.0) as u16, + border_width: 0, + border_color: Color::TRANSPARENT, }; - vec![radio_border, radio_box, radio_circle, label] + vec![radio, radio_circle, label] } else { - vec![radio_border, radio_box, label] + vec![radio, label] }, }, if is_mouse_over { diff --git a/wgpu/src/renderer/widget/scrollable.rs b/wgpu/src/renderer/widget/scrollable.rs index 6ef57185..42a4a743 100644 --- a/wgpu/src/renderer/widget/scrollable.rs +++ b/wgpu/src/renderer/widget/scrollable.rs @@ -1,5 +1,7 @@ use crate::{Primitive, Renderer}; -use iced_native::{scrollable, Background, MouseCursor, Rectangle, Vector}; +use iced_native::{ + scrollable, Background, Color, MouseCursor, Rectangle, Vector, +}; const SCROLLBAR_WIDTH: u16 = 10; const SCROLLBAR_MARGIN: u16 = 2; @@ -68,6 +70,8 @@ impl scrollable::Renderer for Renderer { [0.0, 0.0, 0.0, 0.7].into(), ), border_radius: 5, + border_width: 0, + border_color: Color::TRANSPARENT, }; if is_mouse_over_scrollbar || state.is_scroller_grabbed() { @@ -83,6 +87,8 @@ impl scrollable::Renderer for Renderer { [0.0, 0.0, 0.0, 0.3].into(), ), border_radius: 5, + border_width: 0, + border_color: Color::TRANSPARENT, }; Primitive::Group { diff --git a/wgpu/src/renderer/widget/slider.rs b/wgpu/src/renderer/widget/slider.rs index c73a4e56..386decb5 100644 --- a/wgpu/src/renderer/widget/slider.rs +++ b/wgpu/src/renderer/widget/slider.rs @@ -29,8 +29,10 @@ impl slider::Renderer for Renderer { width: bounds.width, height: 2.0, }, - background: Color::from_rgb(0.6, 0.6, 0.6).into(), + background: Background::Color([0.6, 0.6, 0.6, 0.5].into()), border_radius: 0, + border_width: 0, + border_color: Color::TRANSPARENT, }, Primitive::Quad { bounds: Rectangle { @@ -41,6 +43,8 @@ impl slider::Renderer for Renderer { }, background: Background::Color(Color::WHITE), border_radius: 0, + border_width: 0, + border_color: Color::TRANSPARENT, }, ); @@ -49,41 +53,31 @@ impl slider::Renderer for Renderer { let handle_offset = (bounds.width - HANDLE_WIDTH) * ((value - range_start) / (range_end - range_start).max(1.0)); - let (handle_border, handle) = ( - Primitive::Quad { - bounds: Rectangle { - x: bounds.x + handle_offset.round() - 1.0, - y: rail_y - HANDLE_HEIGHT / 2.0 - 1.0, - width: HANDLE_WIDTH + 2.0, - height: HANDLE_HEIGHT + 2.0, - }, - background: Color::from_rgb(0.6, 0.6, 0.6).into(), - border_radius: 5, + let handle = Primitive::Quad { + bounds: Rectangle { + x: bounds.x + handle_offset.round(), + y: rail_y - HANDLE_HEIGHT / 2.0, + width: HANDLE_WIDTH, + height: HANDLE_HEIGHT, }, - Primitive::Quad { - bounds: Rectangle { - x: bounds.x + handle_offset.round(), - y: rail_y - HANDLE_HEIGHT / 2.0, - width: HANDLE_WIDTH, - height: HANDLE_HEIGHT, - }, - background: Background::Color( - if is_dragging { - [0.85, 0.85, 0.85] - } else if is_mouse_over { - [0.90, 0.90, 0.90] - } else { - [0.95, 0.95, 0.95] - } - .into(), - ), - border_radius: 4, - }, - ); + background: Background::Color( + if is_dragging { + [0.85, 0.85, 0.85] + } else if is_mouse_over { + [0.90, 0.90, 0.90] + } else { + [0.95, 0.95, 0.95] + } + .into(), + ), + border_radius: 4, + border_width: 1, + border_color: Color::from_rgb(0.6, 0.6, 0.6), + }; ( Primitive::Group { - primitives: vec![rail_top, rail_bottom, handle_border, handle], + primitives: vec![rail_top, rail_bottom, handle], }, if is_dragging { MouseCursor::Grabbing diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs index 929f94db..cf3a31ab 100644 --- a/wgpu/src/renderer/widget/text_input.rs +++ b/wgpu/src/renderer/widget/text_input.rs @@ -64,28 +64,17 @@ impl text_input::Renderer for Renderer { ) -> Self::Output { let is_mouse_over = bounds.contains(cursor_position); - let border = Primitive::Quad { - bounds, - background: Background::Color( - if is_mouse_over || state.is_focused() { - [0.5, 0.5, 0.5] - } else { - [0.7, 0.7, 0.7] - } - .into(), - ), - border_radius: 5, - }; - let input = Primitive::Quad { - bounds: Rectangle { - x: bounds.x + 1.0, - y: bounds.y + 1.0, - width: bounds.width - 2.0, - height: bounds.height - 2.0, - }, + bounds, background: Background::Color(Color::WHITE), - border_radius: 4, + border_radius: 5, + border_width: 1, + border_color: if is_mouse_over || state.is_focused() { + [0.5, 0.5, 0.5] + } else { + [0.7, 0.7, 0.7] + } + .into(), }; let text = value.to_string(); @@ -130,6 +119,8 @@ impl text_input::Renderer for Renderer { }, background: Background::Color(Color::BLACK), border_radius: 0, + border_width: 0, + border_color: Color::TRANSPARENT, }; ( @@ -150,7 +141,7 @@ impl text_input::Renderer for Renderer { ( Primitive::Group { - primitives: vec![border, input, contents], + primitives: vec![input, contents], }, if is_mouse_over { MouseCursor::Text diff --git a/wgpu/src/shader/quad.frag b/wgpu/src/shader/quad.frag index 2ee77e71..ad1af1ad 100644 --- a/wgpu/src/shader/quad.frag +++ b/wgpu/src/shader/quad.frag @@ -1,14 +1,17 @@ #version 450 layout(location = 0) in vec4 v_Color; -layout(location = 1) in vec2 v_Pos; -layout(location = 2) in vec2 v_Scale; -layout(location = 3) in float v_BorderRadius; +layout(location = 1) in vec4 v_BorderColor; +layout(location = 2) in vec2 v_Pos; +layout(location = 3) in vec2 v_Scale; +layout(location = 4) in float v_BorderRadius; +layout(location = 5) in float v_BorderWidth; layout(location = 0) out vec4 o_Color; -float rounded(in vec2 frag_coord, in vec2 position, in vec2 size, float radius, float s) +float distance(in vec2 frag_coord, in vec2 position, in vec2 size, float radius) { + // TODO: Try SDF approach: https://www.shadertoy.com/view/wd3XRN vec2 inner_size = size - vec2(radius, radius) * 2.0; vec2 top_left = position + vec2(radius, radius); vec2 bottom_right = top_left + inner_size; @@ -21,13 +24,43 @@ float rounded(in vec2 frag_coord, in vec2 position, in vec2 size, float radius, max(max(top_left_distance.y, bottom_right_distance.y), 0) ); - float d = sqrt(distance.x * distance.x + distance.y * distance.y); - - return 1.0 - smoothstep(radius - s, radius + s, d); + return sqrt(distance.x * distance.x + distance.y * distance.y); } void main() { - float radius_alpha = rounded(gl_FragCoord.xy, v_Pos, v_Scale, v_BorderRadius, 0.5); + vec4 mixed_color; - o_Color = vec4(v_Color.xyz, v_Color.w * radius_alpha); + // TODO: Remove branching (?) + if(v_BorderWidth > 0) { + float internal_border = max(v_BorderRadius - v_BorderWidth, 0); + + float internal_distance = distance( + gl_FragCoord.xy, + v_Pos + vec2(v_BorderWidth), + v_Scale - vec2(v_BorderWidth * 2.0), + internal_border + ); + + float border_mix = smoothstep( + max(internal_border - 0.5, 0.0), + internal_border + 0.5, + internal_distance + ); + + mixed_color = mix(v_Color, v_BorderColor, border_mix); + } else { + mixed_color = v_Color; + } + + float d = distance( + gl_FragCoord.xy, + v_Pos, + v_Scale, + v_BorderRadius + ); + + float radius_alpha = + 1.0 - smoothstep(max(v_BorderRadius - 0.5, 0), v_BorderRadius + 0.5, d); + + o_Color = vec4(mixed_color.xyz, mixed_color.w * radius_alpha); } diff --git a/wgpu/src/shader/quad.frag.spv b/wgpu/src/shader/quad.frag.spv index 17bd8f465ada98f5308097b3ce01c65532cdf70a..519f5f01679be972c5585ee081f5825c4586d435 100644 GIT binary patch literal 4212 zcmZvdXOmP#6o#9yOIng7F~A}!D6*1+NLH{)l&~u1VPI$3(P3wu9ag~v0*Z=&SwRu= zfAFJ!%21`{^W3>dE>qm9Q~katcAq{yGiLO{aVd>T35QKpe^R0qBJ^*73gONZ+9Mqf+Ug>I-m zTy0kC*`CZj8QpO8c!edaHHEcN?yDXhZpBQ8R|f|xjZ(|Y+;h=2>qDhlrN0S8)0yV8 z9;`Q;^&_Q5_3%KhAD0#ud`q$EEM|OK)E0BSy(2BbUI@wR*vFC5HqKOO?63AU2eMq9 zX&-BKuvuvgmTRShnK|>f=i$Ha|8tE?PZ#|QMLdglbhuX9LHoA1y4UKB_cl`6Q>QiL z9-H0aNU8TwxmL-zdl@P>%13hh%Wb^Y#`U}A-;svkt*w`iR9|cL|2R5GrH_lO)f-tI z=Vqj|J?EX-48<8+T4Tqg)A(`qSr~G_Efv`F85u?eNA%DD)*E7UgW+rx%I<7gDmD* zkiDQ*&e`Bjblu1t{C!_?{kq}fS=A}>2|3nh0osYIV*Nt&S%R5w4_0#81G##w&-MjI(AkHTDtq1oG2imyrv}mstxbeQzu*-d?!H}B=)8-Hzk zkarOKB#t~!fSse@PlC;RioDi&3eiV>7due5AMsunBigOGiJJCYo4MTUi-@Wm`j_voV_aI zyV#9~J}>1u^?shyvkkCn6FV#JQ(R*;Z|u!KRr{dLnUSyOSHr&5k*SEe%weoP`Z}N5 zBhM>f^Ta(2gVi;VxCj4W;~uno4-tP9Y`lH7_6VZR`0#lZY~8MWfBfBK`IfVq+ZcV^ zpYyKWSo`({;(HJN7TEV5x!(pGvxlzge*#fg6zgg`iFl44#JuJ@fmqjfrTs7F)|qyG zo#Uu`3hX|@S6=irCVbxo7w`H#xH`qpJ($P0s?9iO;(f$9*5g zna>HV-y!;6LE_w3!Rmv554KLc`yaqp5%qiXIsXxCEx*wH1XgFw(EXh2+(XRhFJR;K z*KU5#c8OKnKV(>k`2XYmdVhWsk+t}ZXPs2QT?ITj$DVZx;v7$7_5aGa>4>uyd~O?` z-^LfV@kMQXNzUz^d2d48L-cY6*nI?_ne+JloCViM{dvx7jyZ_>*+~4R-V8RkHhbkc z)J5G}!1f{P+zKw%y)EZa_jb5G>f=9Q9@sqEtYL4|MU8H-y5I}I?jz#w0CywmjklNT z!v9WiG5#*N_ZVlq8?29d2Hr2=f!3wZ5ZY|@rhiw%&Z2GN4BKI1w^;aWNe=S&j_^bn4zv#0bu0Co! z0FD~QYY*Fof=xf`$DKb2c7OWVA7@ux)ZPeIS3LVBxcczfd;^~?=+wvW#a6I!Tabv` z1~zx`T-)L5!{?zJ_&khGedOK&HctJ?{P$re*qYk9xK;1<5yT!jAKL%rcR-!LEB^t| Cz-KoA literal 3044 zcmZvd?N?M)6o(JOpcYbQN?F;ER+L3*_!bE$C6yE?t<`(u$jrbLaA_E(vM;$>eeI9x zukuT+p6AZpd7IT;>~;3>0P(l4q19Zd&dQhGd%=Ihe(+Vb>X zw=q3)@thvxX*hS(=Lx(NDbLWG(1V1eiTF-rbm!_IDc1##FC$VK$_7ewIIDDpXFX)v0gP*0ZeB=yPLmyV+j5+s^V{%zXrIuYJGC zlGhq%?bI9X{XOw8d%&LCD(NZK_RdbTQ|m`q=OkP=+pTRiTU}I`(NtxW@;>^%~DU$on|*jp$z zzt~S~{=mnGGHw!Y{nbyPjj~pe3H-f}Vr^CMAyzp>e7Ml{nZ)`StGa$6`Y31d*EWIh zEgT2GiBc8uX%|oD=#l?S32VQE3?Y&4R&M`w-hMwvx5fx!e_ycbD?eLcXDX-tt3r1_ z+QrUTdthfA{@)h5HMEPJx%TMiE;`@5`L|Gjfw8=RW4> z%(~i))6d_zbJb=K;;?O?J7aD3Bi7~|+KBVjW^ZD3`?`x^q^qXA!;mu*nDBN4L)J#Mo00(MSGv!TpGC zEx+J?LYK2S&ZGVyB3gSJnzVq<&H+dO9?}Kki=>9(l z{YasE2gXaf?~ZruD64nO9R45hOaq@Bz|{eKW&lqOVBhx0XZ^VXJ6HK*i2cQ!pGLRG zz{d-`%D(kKf#@UuN5MT)@Dr@R72LDv=GNvM-IrX{eGc6jMV;r-%XMEUaMV2o)<^z9 zQR78)^Jue%vyzJ%ljw4RUqZK!h(C?4kG%0!R=Mzh8ND3;3fMD_J-&*rkG%1ogEnF7%W_eB9$l`y_XV(g_*_RH^tqASAH5}u;02`5_hqe6Ts@Bu5o>B2gOU3PaYo)>?e5p#s(j3T8NK`)`55dQ;(ap5Cx|}s5wn6` vj#&j86TRF<*GE2L?x0(Hj2FqgYlyvhr>tR&K2i5m^jnC2fAgM+eJlR~E{@;a diff --git a/wgpu/src/shader/quad.vert b/wgpu/src/shader/quad.vert index 539755cb..1d9a4fd2 100644 --- a/wgpu/src/shader/quad.vert +++ b/wgpu/src/shader/quad.vert @@ -4,7 +4,9 @@ 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 float i_BorderRadius; +layout(location = 4) in vec4 i_BorderColor; +layout(location = 5) in float i_BorderRadius; +layout(location = 6) in float i_BorderWidth; layout (set = 0, binding = 0) uniform Globals { mat4 u_Transform; @@ -12,9 +14,11 @@ layout (set = 0, binding = 0) uniform Globals { }; 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 float o_BorderRadius; +layout(location = 1) out vec4 o_BorderColor; +layout(location = 2) out vec2 o_Pos; +layout(location = 3) out vec2 o_Scale; +layout(location = 4) out float o_BorderRadius; +layout(location = 5) out float o_BorderWidth; void main() { vec2 p_Pos = i_Pos * u_Scale; @@ -28,9 +32,11 @@ void main() { ); o_Color = i_Color; + o_BorderColor = i_BorderColor; o_Pos = p_Pos; o_Scale = p_Scale; o_BorderRadius = i_BorderRadius * u_Scale; + o_BorderWidth = 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 9050adfb01dbe35088d3150834ade4555071ca2b..7059b51bc4575638f541d299aa07e0a12e4f6599 100644 GIT binary patch delta 1267 zcmZXU-D(q26ot=Zl8HY=h!G-ITT3ZYycQ~=5F=<2A^ovct0pm-j$>kHOj3WYa^(Yz zbL|^=*C+7G8(+W+pTK7jT;F64gc?|!z1Ci5pR@NI^0WT!QpGK-l#Ovr*_<*TlFALI zmNb`FTgI48VMo{%o(lUyN9YQn5GS904?Kf4YTu1UeSg%9hS5m8WV~#9_@7?PN=EHg zG|qg*tbEko?sbQLwvVH1y{&FPJd%-m`)T6TH#&3Ky|6!domKH>m @*8}B)VY}sz zcKy-B|0t?jo(a>jSMy>Z9*_^bQJnch7v;UuM{&dTePS6WYNAf zbX(I`%szCQ=x9Zw#z5zrp$J777zZ(=w*tE5hl-bkFWN*t67ZnoVN&meSlG;);XeY6 xpVh{S(fHym?W*v`CIV)X*MwCeQ4v1Pk-%YixG`_~y};+@!gK`3_g7`tg?}OJgCYO` delta 913 zcmX|;%W6|m6o&UXiHR4Yq*bC;ts)}Qkpn>}3Rm`>a$Cw%$Nh>%D4jed) z=P3kdeF!H`d;p)okq;pFeeoO*e5}3x_3yRU-skJt@3l%HzFZC=3gvJ(>`p2-q7##) zOQ%*t2B$@+L?xp2F-dh+DJzG$$L_2rO-&P$F-=DuEcZa^~C>tON0K~d;Pur_HHM^RmS%r zo~yK|`gwjY{StqxI@JY;VA-kCNnyU~=&D7ykGqlnF3hgjU*EATPAjZEQ>_5G=331T z%T)5&JfnB;u=pz)Uu0RQtd*w>i&^eSYI*K^n(Kd@txH+m+_%o_Pgpx*UN`qLYUkMh zBCA~sVVfKBeh8IJv?w0bB-+%vgP6BKZGn7-*akoS+eF{tIOso0>>X^C3&pW_TZ1ET zn+D#`{1!HAkKi;|^RDLByu%ha{~dn9N#awe!Yt&TXPN#Hk9(ej`_$< zHgSHNICB@&^E_ca51-j%{Uzv8*W=)?pa-kj!Tn4l{MU9oQDX#kw)xnvLGun=g)1vgyKzsu&aA04_T;CtM-h{t<30h_V