struct VSInput {
    float2 pos;
    float2 scale;
    float2 uv;
    float4 color;
    float alpha;
    uint32_t textureID;

    uint vertex_index : SV_VertexID;
};

struct VSOutput {
    float4 pos : SV_POSITION;
    float2 uv;
    float4 color;
    float alpha;
    uint32_t tex_id;
};

Sampler2D textures[];

static const float2 square[6] = {
    float2(-0.5, -0.5), // Top-left
    float2(-0.5,  0.5), // Bottom-left
    float2( 0.5, -0.5), // Top-right

    float2( 0.5, -0.5), // Top-right
    float2(-0.5,  0.5), // Bottom-left
    float2( 0.5,  0.5)  // Bottom-right
};

[shader ("vertex")]
VSOutput main(VSInput input, uniform float4x4 proj) {
    VSOutput output;

    float2 vertex_pos = square[input.vertex_index % 6];
    float2 final_pos = (vertex_pos * input.scale) + input.pos;

    output.pos = mul(proj, float4(final_pos, 0.0, 1.0));
    output.uv = input.uv;
    output.color = input.color;
    output.alpha = input.alpha;
    output.tex_id = input.textureID;

    return output;
}

[shader("fragment")]
float4 main(VSOutput input) {

    return float4(input.color.rgb, input.alpha);
}
