2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
2019-12-17 15:06:28 +00:00
|
|
|
uniform vec4 u_color;
|
|
|
|
|
|
|
|
_OUT_ vec4 final_color;
|
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
|
|
|
|
|
|
|
final_color = u_color;
|
|
|
|
final_color.rgb *= final_color.a; // pre-multiply
|
|
|
|
final_color *= u_alpha;
|
2019-12-14 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
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
|
|
|
|
2019-12-17 15:06:28 +00:00
|
|
|
_IN_ vec4 final_color;
|
|
|
|
|
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
|
|
|
|
2020-01-19 16:11:57 +00:00
|
|
|
rounded_rect_transform(outside, u_modelview);
|
|
|
|
rounded_rect_transform(inside, u_modelview);
|
|
|
|
|
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);
|
|
|
|
|
2019-12-17 15:06:28 +00:00
|
|
|
setOutputColor(final_color * alpha);
|
2017-12-01 10:55:10 +00:00
|
|
|
}
|