[[vertex]]

in vec4 pos;
in vec2 uvs;
in mat4 a_mvp;
in float a_flow;
out vec3 uv;
out float alpha;

void main()
{
    uv = vec3(uvs, pos.w);
    alpha = a_flow;
    gl_Position = a_mvp * vec4(pos.xyz, 1.0);
}

[[fragment]]

uniform mediump sampler2D tex;
uniform mediump sampler2D tex_pattern;
uniform mediump vec4 col;
uniform mediump vec2 resolution;
uniform mediump vec2 pattern_offset;
uniform mediump float pattern_alpha;

in mediump float alpha;
in mediump vec3 uv;
out mediump vec4 frag;

void main()
{
    mediump vec2 uv2 = gl_FragCoord.st / resolution;
    mediump float pattern = 1.0 - (texture(tex_pattern, (uv2+pattern_offset)).r * 0.9) * pattern_alpha;
    mediump float a = (1.0 - texture(tex, uv.xy).r) * alpha * pattern;
    frag = vec4(col.rgb, a);
}
