2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
2019-12-17 15:46:05 +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:46:05 +00:00
|
|
|
|
|
|
|
final_color = u_color;
|
|
|
|
final_color.rgb *= final_color.a;
|
|
|
|
final_color *= u_alpha;
|
2019-12-14 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
2017-11-30 17:47:55 +00:00
|
|
|
uniform float u_spread;
|
|
|
|
uniform vec2 u_offset;
|
2019-12-16 05:16:26 +00:00
|
|
|
uniform vec4[3] u_outline_rect;
|
2017-11-30 15:48:03 +00:00
|
|
|
|
2019-12-17 15:46:05 +00:00
|
|
|
_IN_ vec4 final_color;
|
|
|
|
|
2017-11-30 15:48:03 +00:00
|
|
|
void main() {
|
|
|
|
vec4 f = gl_FragCoord;
|
2019-12-17 15:46:05 +00:00
|
|
|
vec4 color;
|
2017-11-30 15:48:03 +00:00
|
|
|
|
2017-11-30 17:47:55 +00:00
|
|
|
f.x += u_viewport.x;
|
|
|
|
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
2017-11-30 15:48:03 +00:00
|
|
|
|
2019-12-16 05:16:26 +00:00
|
|
|
RoundedRect outside = create_rect(u_outline_rect);
|
|
|
|
RoundedRect inside = rounded_rect_shrink(outside, vec4(u_spread));
|
2019-12-17 15:46:05 +00:00
|
|
|
color = final_color * clamp (rounded_rect_coverage (outside, f.xy) -
|
|
|
|
rounded_rect_coverage (inside, f.xy - u_offset),
|
|
|
|
0.0, 1.0);
|
|
|
|
setOutputColor(color);
|
2017-11-30 15:48:03 +00:00
|
|
|
}
|