[[vertex]]

uniform mat4 mvp;

in vec4 pos;
in vec2 uvs;
out vec2 uv;

void main()
{
    uv = uvs;
    gl_Position = mvp * vec4(pos.xyz, 1.0);
}

[[fragment]]

uniform sampler2D tex;
uniform sampler2D tex_alpha;
uniform sampler2D tex_bg;
uniform mediump float alpha;
uniform bool highlight;

in mediump vec2 uv;
out mediump vec4 frag;

void main()
{
    mediump vec3 rgb = texture(tex, uv).rgb;
    mediump float a = texture(tex_alpha, uv).a;
    mediump vec4 c = vec4(rgb, a);
    frag = highlight ? 
        vec4(clamp(vec3(0.3) + c.rgb, vec3(0.0), vec3(1.0)), c.a) : 
        texture(tex, uv) * vec4(1.0, 1.0, 1.0, alpha);
}
