aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-21 18:38:25 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-21 18:38:25 +0200
commit52ca136fa387f3b838cabf540f957ef916997d2b (patch)
tree6293df39d5fee694f06964b3ca1efadf3489b0ca
parenta573a3f1a30e3e06ef0ffb0731f6a6db3419cc42 (diff)
clamp shaders
-rw-r--r--shaders/rounded_rectangle.glsl4
-rw-r--r--shaders/rounded_rectangle_mask.glsl2
-rw-r--r--shaders/rounded_rectangle_no_shadow.glsl2
3 files changed, 4 insertions, 4 deletions
diff --git a/shaders/rounded_rectangle.glsl b/shaders/rounded_rectangle.glsl
index 7c797f2..ec3a5c1 100644
--- a/shaders/rounded_rectangle.glsl
+++ b/shaders/rounded_rectangle.glsl
@@ -15,11 +15,11 @@ void main() {
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);
+ float a = clamp(1.0 - smoothstep(0.0, 2.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 = 1.0 - smoothstep(0.0, shadow_offset.x, rect_dist);
+ 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));
} \ No newline at end of file
diff --git a/shaders/rounded_rectangle_mask.glsl b/shaders/rounded_rectangle_mask.glsl
index 8cbe0fc..2ee2888 100644
--- a/shaders/rounded_rectangle_mask.glsl
+++ b/shaders/rounded_rectangle_mask.glsl
@@ -12,7 +12,7 @@ void main() {
vec2 size = resolution * 0.5;
vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy);
- float a = 1.0 - smoothstep(0.0, 2.0, rounded_rect(uv - center, size, radius));
+ float a = clamp(1.0 - smoothstep(0.0, 2.0, rounded_rect(uv - center, size, radius)), 0.0, 1.0);
texture_color.a *= a;
gl_FragColor = texture_color;
} \ No newline at end of file
diff --git a/shaders/rounded_rectangle_no_shadow.glsl b/shaders/rounded_rectangle_no_shadow.glsl
index 4fc32cf..e5915da 100644
--- a/shaders/rounded_rectangle_no_shadow.glsl
+++ b/shaders/rounded_rectangle_no_shadow.glsl
@@ -15,7 +15,7 @@ void main() {
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);
+ float a = clamp(1.0 - smoothstep(0.0, 2.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);