2022-11-10 17:32:28 +11:00
|
|
|
precision mediump float;
|
|
|
|
varying vec2 v_texcoord;
|
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform float alpha;
|
2022-12-07 16:10:11 +11:00
|
|
|
uniform float dim;
|
|
|
|
uniform vec4 dim_color;
|
2022-11-10 17:32:28 +11:00
|
|
|
|
|
|
|
uniform vec2 size;
|
|
|
|
uniform vec2 position;
|
|
|
|
uniform float radius;
|
2022-11-11 17:19:02 +11:00
|
|
|
uniform bool has_titlebar;
|
2022-11-12 11:38:09 +11:00
|
|
|
uniform float saturation;
|
|
|
|
const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721);
|
2022-11-10 17:32:28 +11:00
|
|
|
|
|
|
|
void main() {
|
2022-12-07 16:10:11 +11:00
|
|
|
vec4 color = texture2D(tex, v_texcoord);
|
2022-11-12 11:38:09 +11:00
|
|
|
// Saturation
|
|
|
|
if (saturation != 1.0) {
|
|
|
|
vec4 pixColor = texture2D(tex, v_texcoord);
|
|
|
|
vec3 irgb = pixColor.rgb;
|
|
|
|
vec3 target = vec3(dot(irgb, saturation_weight));
|
2022-12-07 16:10:11 +11:00
|
|
|
color = vec4(mix(target, irgb, saturation), pixColor.a);
|
2022-11-12 11:38:09 +11:00
|
|
|
}
|
2022-12-07 16:10:11 +11:00
|
|
|
// Dimming
|
|
|
|
gl_FragColor = mix(color, dim_color, dim) * alpha;
|
2022-11-12 11:38:09 +11:00
|
|
|
|
2022-11-11 17:19:02 +11:00
|
|
|
if (!has_titlebar || gl_FragCoord.y - position.y > radius) {
|
|
|
|
vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);
|
|
|
|
if (max(corner_distance.x, corner_distance.y) < radius) {
|
|
|
|
float d = radius - distance(corner_distance, vec2(radius));
|
|
|
|
float smooth = smoothstep(-1.0f, 0.5f, d);
|
|
|
|
gl_FragColor = mix(vec4(0), gl_FragColor, smooth);
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 17:32:28 +11:00
|
|
|
}
|