
uniform sampler2DArray u_textures;

in vec2 v_uv;
in vec4 v_color;
flat in vec4 v_texture_info;
flat in int v_atlas;
out vec4 frag_color;


void main() {
    ivec3 texture_size = textureSize(u_textures, 0);
    vec4 col = texture(u_textures, vec3(
        (vec2(v_texture_info.xy) + vec2(v_texture_info.zw) * v_uv) / vec2(texture_size.xy),
        float(v_atlas))
    ) * v_color.rgba;
    if (col.a <= 0.0) discard;
    frag_color = col;
}
