#version 450
#include "common.glsl"

layout(
    set = GLSL_GUI_DESCRIPTOR_SET,
    binding = GLSL_COLOR_IMAGE_INDEX
) uniform sampler2D uColorSampler;

layout(
    set = GLSL_GUI_DESCRIPTOR_SET,
    binding = GLSL_IMAGE_METADATA_INDEX,
    std140
) uniform MetadataBlock
{
    ivec2 size;
    int flags;
} metadata;

layout(location = 0) in vec2 inTexCoords;
layout(location = 1) in vec4 inColor;

layout(location = 0) out vec4 outColor;

void main() {
    vec4 blend = inColor;
    if ((metadata.flags & GLSL_MAT_FIXED_COLOR) != 0)
    {
        blend = vec4(vec3(1.0), inColor.a);
    }

    outColor = blend * texture(uColorSampler, inTexCoords);
}