aboutsummaryrefslogtreecommitdiffstats
path: root/config/cava/shaders/normalized_bars.frag
blob: 81a27e2d53da418109f03e5976d92c8d4b395358 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;

}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage