From 9d2fbadd55a1c7c89660fcec430a945867ded527 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 21 Jun 2021 18:19:10 +0200 Subject: Add theme option to disable rounded rectangle drop shadow --- shaders/rounded_rectangle_no_shadow.glsl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 shaders/rounded_rectangle_no_shadow.glsl (limited to 'shaders/rounded_rectangle_no_shadow.glsl') diff --git a/shaders/rounded_rectangle_no_shadow.glsl b/shaders/rounded_rectangle_no_shadow.glsl new file mode 100644 index 0000000..4fc32cf --- /dev/null +++ b/shaders/rounded_rectangle_no_shadow.glsl @@ -0,0 +1,24 @@ +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) { + return length(max(abs(coord) - size+r, 0.0)) - r; +} + +void main() { + vec2 shadow_offset = vec2(20.0, 20.0); + vec2 uv = gl_TexCoord[0].xy * resolution; + vec2 center = resolution * 0.5; + vec2 size = (resolution - shadow_offset * 2.0) * 0.5; + + float rect_dist = rounded_rect(uv - center, size, radius); + float a = 1.0 - smoothstep(0.0, 2.0, rect_dist); + // 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; +} \ No newline at end of file -- cgit v1.2.3