2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
2018-03-15 16:27:19 +00:00
|
|
|
uniform vec4 u_color;
|
2017-12-01 10:55:10 +00:00
|
|
|
uniform vec4 u_widths;
|
2019-12-16 05:16:26 +00:00
|
|
|
uniform vec4[3] u_outline_rect;
|
2018-03-15 16:27:19 +00:00
|
|
|
|
2017-12-01 10:55:10 +00:00
|
|
|
void main() {
|
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;
|
|
|
|
|
2019-12-16 05:16:26 +00:00
|
|
|
RoundedRect outside = create_rect(u_outline_rect);
|
|
|
|
RoundedRect inside = rounded_rect_shrink (outside, u_widths);
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2019-12-16 05:16:26 +00:00
|
|
|
float alpha = clamp (rounded_rect_coverage (outside, f.xy) -
|
|
|
|
rounded_rect_coverage (inside, f.xy),
|
2017-12-01 10:55:10 +00:00
|
|
|
0.0, 1.0);
|
|
|
|
|
|
|
|
/* Pre-multiply */
|
|
|
|
vec4 color = u_color;
|
|
|
|
color.rgb *= color.a;
|
|
|
|
|
|
|
|
setOutputColor (color * alpha * u_alpha);
|
|
|
|
}
|