
uniform sampler2DArray u_textures;
uniform vec4 u_color;

in vec2 v_uv;
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))
    );
    frag_color = u_color * vec4(1.0, 1.0, 1.0, col.r);
}
