#version 330 core

in vec2 vUV;
out vec4 FragColor;

uniform sampler2D uTex;
uniform vec2 uUVMin;
uniform vec2 uUVMax;

void main()
{
    // Rotate UV 90 degrees to the right: (x, y) → (y, 1 - x)
    vec2 rotatedUV = vec2(vUV.y, 1.0 - vUV.x);

    // Interpolate UVs within atlas range
    vec2 uv = mix(uUVMin, uUVMax, rotatedUV);

    vec4 color = texture(uTex, uv);
    if (color.a < 0.01)
        discard;

    FragColor = color;
}
