aboutsummaryrefslogtreecommitdiff
path: root/shaders/rounded_rectangle.glsl
blob: 7da082689678e5a7733a27b9d978471c4e97656c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
uniform float radius;
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);
    gl_FragColor = mix(gl_Color, background_color, a);
}