#version 330

uniform WindowBlock {
    mat4 projection;
    mat4 view;
} window;

uniform vec2 offset;
uniform float rotation;  // Rotation angle in radians

in vec2 in_vert;
in vec2 in_uv;

in vec2 in_instance_position;
in float in_instance_radius;
in float in_instance_attenuation;
in vec3 in_instance_color;

out float attenuation;
out vec3 color;
out vec2 uv;

void main() {
    // Apply rotation to vertex
    float cos_r = cos(rotation);
    float sin_r = sin(rotation);
    vec2 rotated = vec2(
        in_vert.x * cos_r - in_vert.y * sin_r,
        in_vert.x * sin_r + in_vert.y * cos_r
    );
    
    vec2 position = (rotated * in_instance_radius) + in_instance_position + offset;
    gl_Position = window.projection * window.view * vec4(position, 0.0, 1.0);
    uv = in_uv;
    attenuation = in_instance_attenuation;
    color = in_instance_color / 255.0;
}
