aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'shaders')
-rw-r--r--shaders/rounded_rectangle.glsl13
-rw-r--r--shaders/rounded_rectangle_mask.glsl6
2 files changed, 11 insertions, 8 deletions
diff --git a/shaders/rounded_rectangle.glsl b/shaders/rounded_rectangle.glsl
index 956e28e..8c379b7 100644
--- a/shaders/rounded_rectangle.glsl
+++ b/shaders/rounded_rectangle.glsl
@@ -5,18 +5,21 @@ uniform vec4 band_color;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
- return smoothstep(0.0, 2.0, length(max(abs(coord) - size, 0.0)) - 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 * 0.5;
+ vec2 size = (resolution - shadow_offset * 2.0) * 0.5;
- float a = clamp(rounded_rect(uv - center, size - radius, radius), 0.0, 1.0);
+ 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 *= (1.0 - a);
- gl_FragColor = front_color;
+ float shadow_a = 1.0 - smoothstep(0.0, shadow_offset.x, rect_dist);
+ front_color.a *= a;
+ gl_FragColor = mix(front_color, vec4(0.0, 0.0, 0.0, 0.135), shadow_a - a);
} \ No newline at end of file
diff --git a/shaders/rounded_rectangle_mask.glsl b/shaders/rounded_rectangle_mask.glsl
index a4546e3..8cbe0fc 100644
--- a/shaders/rounded_rectangle_mask.glsl
+++ b/shaders/rounded_rectangle_mask.glsl
@@ -3,7 +3,7 @@ uniform float radius;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
- return smoothstep(0.0, 2.0, length(max(abs(coord) - size, 0.0)) - r);
+ return length(max(abs(coord) - size+r, 0.0)) - r;
}
void main() {
@@ -12,7 +12,7 @@ void main() {
vec2 size = resolution * 0.5;
vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy);
- float a = clamp(rounded_rect(uv - center, size - radius, radius), 0.0, 1.0);
- texture_color.a *= (1.0 - a);
+ float a = 1.0 - smoothstep(0.0, 2.0, rounded_rect(uv - center, size, radius));
+ texture_color.a *= a;
gl_FragColor = texture_color;
} \ No newline at end of file