2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
2019-12-17 15:46:05 +00:00
|
|
|
uniform vec4 u_color;
|
2020-01-19 19:08:23 +00:00
|
|
|
uniform float u_spread;
|
|
|
|
uniform vec2 u_offset;
|
|
|
|
uniform vec4[3] u_outline_rect;
|
2019-12-17 15:46:05 +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-17 15:46:05 +00:00
|
|
|
|
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:46:05 +00:00
|
|
|
|
|
|
|
final_color = u_color;
|
|
|
|
final_color.rgb *= final_color.a;
|
|
|
|
final_color *= u_alpha;
|
2020-01-19 19:08:23 +00:00
|
|
|
|
|
|
|
RoundedRect outside = create_rect(u_outline_rect);
|
|
|
|
RoundedRect inside = rounded_rect_shrink(outside, vec4(u_spread));
|
|
|
|
|
|
|
|
rounded_rect_offset(inside, u_offset);
|
|
|
|
|
|
|
|
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-17 15:46:05 +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:46:05 +00:00
|
|
|
|
2017-11-30 15:48:03 +00:00
|
|
|
void main() {
|
2020-05-10 07:20:53 +00:00
|
|
|
vec2 frag = get_frag_coord();
|
2017-11-30 15:48:03 +00:00
|
|
|
|
2020-07-24 06:49:24 +00:00
|
|
|
float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), frag) -
|
|
|
|
rounded_rect_coverage(decode_rect(transformed_inside_outline), frag),
|
|
|
|
0.0, 1.0);
|
2020-01-19 16:11:57 +00:00
|
|
|
|
|
|
|
setOutputColor(final_color * alpha);
|
2017-11-30 15:48:03 +00:00
|
|
|
}
|