aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-18 17:03:11 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-18 17:03:11 +0200
commit63774155016ad581dcf418c94cd2ec84fcf86445 (patch)
treece4a9939d2555dce80792a06d1361b9f5d8b8ec0 /shaders
parent86d23983d8c9cd75af9c40f038f6b9a1f0b5fbb5 (diff)
Render selected item background as a rectangle on top instead of banding
Limit selected item background position to body content position and size
Diffstat (limited to 'shaders')
-rw-r--r--shaders/rounded_rectangle.glsl9
-rw-r--r--shaders/rounded_rectangle_no_shadow.glsl9
2 files changed, 2 insertions, 16 deletions
diff --git a/shaders/rounded_rectangle.glsl b/shaders/rounded_rectangle.glsl
index 2863584..40babe2 100644
--- a/shaders/rounded_rectangle.glsl
+++ b/shaders/rounded_rectangle.glsl
@@ -1,7 +1,4 @@
uniform float radius;
-uniform vec2 band_pos;
-uniform vec2 band_size;
-uniform vec4 band_color;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
@@ -16,10 +13,6 @@ void main() {
float rect_dist = rounded_rect(uv - center, size, radius);
float a = clamp(1.0 - smoothstep(0.0, 1.0, rect_dist), 0.0, 1.0);
- // same as: if(uv.x >= band_pos.x && uv.x <= band_pos.x + band_size.x && uv.y >= band_pos.y && uv.y <= band_pos.y + band_size.y)
- vec2 band_blend = step(band_pos, uv) - step(band_pos + band_size, uv);
- vec4 front_color = mix(gl_Color, band_color, band_blend.x*band_blend.y);
float shadow_a = clamp(1.0 - smoothstep(0.0, shadow_offset.x, rect_dist), 0.0, 1.0);
- front_color.a *= a;
- gl_FragColor = mix(front_color, vec4(0.0, 0.0, 0.0, 0.14), clamp(shadow_a - a, 0.0, 1.0));
+ gl_FragColor = mix(vec4(gl_Color.rgb, a), vec4(0.0, 0.0, 0.0, 0.14), clamp(shadow_a - a, 0.0, 1.0));
} \ No newline at end of file
diff --git a/shaders/rounded_rectangle_no_shadow.glsl b/shaders/rounded_rectangle_no_shadow.glsl
index c32f842..b12b35c 100644
--- a/shaders/rounded_rectangle_no_shadow.glsl
+++ b/shaders/rounded_rectangle_no_shadow.glsl
@@ -1,7 +1,4 @@
uniform float radius;
-uniform vec2 band_pos;
-uniform vec2 band_size;
-uniform vec4 band_color;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
@@ -16,9 +13,5 @@ void main() {
float rect_dist = rounded_rect(uv - center, size, radius);
float a = clamp(1.0 - smoothstep(0.0, 1.0, rect_dist), 0.0, 1.0);
- // same as: if(uv.x >= band_pos.x && uv.x <= band_pos.x + band_size.x && uv.y >= band_pos.y && uv.y <= band_pos.y + band_size.y)
- vec2 band_blend = step(band_pos, uv) - step(band_pos + band_size, uv);
- vec4 front_color = mix(gl_Color, band_color, band_blend.x*band_blend.y);
- front_color.a *= a;
- gl_FragColor = front_color;
+ gl_FragColor = vec4(gl_Color.rgb, a);
} \ No newline at end of file