aboutsummaryrefslogtreecommitdiff
path: root/shaders/rounded_rectangle.glsl
blob: 88a057a82d6c1e395a7ff8cb3b2b94ced861e139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uniform float radius;
uniform vec2 band_pos;
uniform vec2 band_size;
uniform vec4 band_color;
uniform vec2 resolution;

float rounded_rect(vec2 coord, vec2 size, float r) {
	return length(max(abs(coord) - size, 0.0)) - r;
}

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);
}