2018-03-15 16:27:19 +00:00
|
|
|
uniform vec4 u_color;
|
2017-12-01 10:55:10 +00:00
|
|
|
uniform vec4 u_widths;
|
|
|
|
|
2018-03-15 16:27:19 +00:00
|
|
|
uniform vec4 u_outline;
|
|
|
|
uniform vec4 u_corner_widths;
|
|
|
|
uniform vec4 u_corner_heights;
|
|
|
|
|
2017-12-01 10:55:10 +00:00
|
|
|
void main() {
|
2018-03-15 16:27:19 +00:00
|
|
|
vec4 bounds = u_outline;
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2018-03-15 16:27:19 +00:00
|
|
|
bounds.z = bounds.x + bounds.z;
|
|
|
|
bounds.w = bounds.y + bounds.w;
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2018-03-15 16:27:19 +00:00
|
|
|
vec4 f = gl_FragCoord;
|
2017-12-01 10:55:10 +00:00
|
|
|
f.x += u_viewport.x;
|
|
|
|
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
|
|
|
|
2018-03-15 16:27:19 +00:00
|
|
|
RoundedRect routside = RoundedRect (bounds, u_corner_widths, u_corner_heights);
|
2017-12-01 10:55:10 +00:00
|
|
|
RoundedRect rinside = rounded_rect_shrink (routside, u_widths);
|
|
|
|
|
|
|
|
float alpha = clamp (rounded_rect_coverage (routside, f.xy) -
|
|
|
|
rounded_rect_coverage (rinside, f.xy),
|
|
|
|
0.0, 1.0);
|
|
|
|
|
|
|
|
/* Pre-multiply */
|
|
|
|
vec4 color = u_color;
|
|
|
|
color.rgb *= color.a;
|
|
|
|
|
|
|
|
setOutputColor (color * alpha * u_alpha);
|
|
|
|
}
|