diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/cava/shaders/normalized_bars.frag | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/cava/shaders/normalized_bars.frag')
| -rw-r--r-- | config/cava/shaders/normalized_bars.frag | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/config/cava/shaders/normalized_bars.frag b/config/cava/shaders/normalized_bars.frag new file mode 100644 index 00000000..81a27e2d --- /dev/null +++ b/config/cava/shaders/normalized_bars.frag @@ -0,0 +1,38 @@ +#version 330 + +in vec2 fragCoord; +out vec4 fragColor; + +// bar values. defaults to left channels first (low to high), then right (high to low). +uniform float bars[512]; + +uniform int bars_count; // number of bars (left + right) (configurable) + +uniform vec3 u_resolution; // window resolution, not used here + +//colors, configurable in cava config file +uniform vec3 bg_color; // background color(r,g,b) (0.0 - 1.0), not used here +uniform vec3 fg_color; // foreground color, not used here + +float normalize_C(float x, float x_min, float x_max, float r_min, float r_max ) +{ + float xr; + xr = (r_max-r_min) * (x - x_min) / (x_max - x_min) + r_min; + return xr; +} + +void main() +{ + // find which bar to use based on where we are on the x axis + int bar = int(bars_count * fragCoord.x); + + // create a normal along the y axis based on the bar height + float x = normalize_C(fragCoord.y, 1.0, 0.0, 0.0, bars[bar]); + + // set color + fragColor.r=fg_color.x*x; + fragColor.g=fg_color.y*x; + fragColor.b=fg_color.z*x; + fragColor.a=1.0; + +} |
