diff options
Diffstat (limited to 'wgpu/src/shader')
-rw-r--r-- | wgpu/src/shader/quad.frag | 12 | ||||
-rw-r--r-- | wgpu/src/shader/quad.frag.spv | bin | 2900 -> 3196 bytes | |||
-rw-r--r-- | wgpu/src/shader/quad.vert | 3 | ||||
-rw-r--r-- | wgpu/src/shader/quad.vert.spv | bin | 2364 -> 2544 bytes |
4 files changed, 11 insertions, 4 deletions
diff --git a/wgpu/src/shader/quad.frag b/wgpu/src/shader/quad.frag index 1fc28bc1..987744db 100644 --- a/wgpu/src/shader/quad.frag +++ b/wgpu/src/shader/quad.frag @@ -3,6 +3,7 @@ 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 flat uint v_BorderRadius; layout(location = 0) out vec4 o_Color; @@ -26,8 +27,11 @@ float rounded(in vec2 frag_coord, in vec2 position, in vec2 size, float radius, } void main() { - o_Color = vec4( - v_Color.xyz, - v_Color.w * rounded(gl_FragCoord.xy, v_Pos, v_Scale, 5.0, 1.0) - ); + float radius_alpha = 1.0; + + if(v_BorderRadius > 0.0) { + radius_alpha = rounded(gl_FragCoord.xy, v_Pos, v_Scale, v_BorderRadius, 1.0); + } + + o_Color = vec4(v_Color.xyz, v_Color.w * radius_alpha); } diff --git a/wgpu/src/shader/quad.frag.spv b/wgpu/src/shader/quad.frag.spv Binary files differindex 19733ecf..063287b3 100644 --- a/wgpu/src/shader/quad.frag.spv +++ b/wgpu/src/shader/quad.frag.spv diff --git a/wgpu/src/shader/quad.vert b/wgpu/src/shader/quad.vert index 87f6cc53..b7c5cf3e 100644 --- a/wgpu/src/shader/quad.vert +++ b/wgpu/src/shader/quad.vert @@ -4,6 +4,7 @@ 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 (set = 0, binding = 0) uniform Globals { mat4 u_Transform; @@ -12,6 +13,7 @@ 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 uint o_BorderRadius; void main() { mat4 i_Transform = mat4( @@ -24,6 +26,7 @@ void main() { o_Color = i_Color; o_Pos = i_Pos; o_Scale = i_Scale; + o_BorderRadius = i_BorderRadius; 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 0d13df6c..f62a160c 100644 --- a/wgpu/src/shader/quad.vert.spv +++ b/wgpu/src/shader/quad.vert.spv |