2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
2019-12-17 15:06:28 +00:00
|
|
|
uniform vec4 u_color;
|
2020-01-19 19:08:23 +00:00
|
|
|
uniform vec4 u_widths;
|
|
|
|
uniform vec4[3] u_outline_rect;
|
2019-12-17 15:06:28 +00:00
|
|
|
|
|
|
|
_OUT_ vec4 final_color;
|
2020-01-19 19:08:23 +00:00
|
|
|
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
|
|
|
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
2019-12-14 21:06:12 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
2019-12-17 15:06:28 +00:00
|
|
|
|
2020-09-18 13:26:58 +00:00
|
|
|
final_color = premultiply(u_color) * u_alpha;
|
2020-01-19 19:08:23 +00:00
|
|
|
|
|
|
|
RoundedRect outside = create_rect(u_outline_rect);
|
|
|
|
RoundedRect inside = rounded_rect_shrink (outside, u_widths);
|
|
|
|
|
|
|
|
rounded_rect_transform(outside, u_modelview);
|
|
|
|
rounded_rect_transform(inside, u_modelview);
|
|
|
|
|
|
|
|
rounded_rect_encode(outside, transformed_outside_outline);
|
|
|
|
rounded_rect_encode(inside, transformed_inside_outline);
|
2019-12-14 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
2019-12-16 05:16:26 +00:00
|
|
|
uniform vec4[3] u_outline_rect;
|
2018-03-15 16:27:19 +00:00
|
|
|
|
2019-12-17 15:06:28 +00:00
|
|
|
_IN_ vec4 final_color;
|
2020-01-19 19:08:23 +00:00
|
|
|
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
|
|
|
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
2019-12-17 15:06:28 +00:00
|
|
|
|
2017-12-01 10:55:10 +00:00
|
|
|
void main() {
|
2020-05-10 07:20:53 +00:00
|
|
|
vec2 frag = get_frag_coord();
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2020-05-10 07:20:53 +00:00
|
|
|
float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), frag) -
|
|
|
|
rounded_rect_coverage(decode_rect(transformed_inside_outline), frag),
|
2020-01-19 19:08:23 +00:00
|
|
|
0.0, 1.0);
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2019-12-17 15:06:28 +00:00
|
|
|
setOutputColor(final_color * alpha);
|
2017-12-01 10:55:10 +00:00
|
|
|
}
|