diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-11 17:11:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-11 17:11:13 +0200 |
commit | c96fdcb4d639ae52ad1d2c812a07e5667849fe71 (patch) | |
tree | 37ace7d7fbb79a211d604a9e7a3204e454ee8720 /shaders | |
parent | 26b593b1eac483f700c72b4195e372f4b92acc7f (diff) |
Optimize shaders, only update youtube decryption function once every 5 minutes, smoother movement with smaller card items
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/circle_mask.glsl | 4 | ||||
-rw-r--r-- | shaders/rounded_rectangle.glsl | 11 | ||||
-rw-r--r-- | shaders/rounded_rectangle_mask.glsl | 5 |
3 files changed, 10 insertions, 10 deletions
diff --git a/shaders/circle_mask.glsl b/shaders/circle_mask.glsl index 198191e..61c87cb 100644 --- a/shaders/circle_mask.glsl +++ b/shaders/circle_mask.glsl @@ -13,7 +13,5 @@ void main() { float radius = 0.49 * resolution.y; vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy); - vec4 layer1 = vec4(0.0, 0.0, 0.0, 0.0); - vec4 layer2 = circle(uv, center, radius, texture_color); - gl_FragColor = mix(layer1, layer2, layer2.a); + gl_FragColor = circle(uv, center, radius, texture_color); } diff --git a/shaders/rounded_rectangle.glsl b/shaders/rounded_rectangle.glsl index 88a057a..d06a4ba 100644 --- a/shaders/rounded_rectangle.glsl +++ b/shaders/rounded_rectangle.glsl @@ -12,10 +12,11 @@ void main() { vec2 uv = gl_TexCoord[0].xy * resolution; vec2 center = resolution * 0.5; vec2 size = resolution * 0.5; - vec4 background_color = vec4(0.0, 0.0, 0.0, 0.0); + float a = clamp(rounded_rect(uv - center, size - radius, radius), 0.0, 1.0); - vec4 front_color = gl_Color; - 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) - front_color = band_color; - gl_FragColor = mix(front_color, background_color, a); + // 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; }
\ No newline at end of file diff --git a/shaders/rounded_rectangle_mask.glsl b/shaders/rounded_rectangle_mask.glsl index 4725273..f6ff1a1 100644 --- a/shaders/rounded_rectangle_mask.glsl +++ b/shaders/rounded_rectangle_mask.glsl @@ -10,8 +10,9 @@ void main() { vec2 uv = gl_TexCoord[0].xy * resolution; vec2 center = resolution * 0.5; vec2 size = resolution * 0.5; - vec4 background_color = vec4(0.0, 0.0, 0.0, 0.0); + vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy); float a = clamp(rounded_rect(uv - center, size - radius, radius), 0.0, 1.0); - gl_FragColor = mix(texture_color, background_color, a); + texture_color.a *= (1.0 - a); + gl_FragColor = texture_color; }
\ No newline at end of file |