#version 330 core

layout(location = 0) in vec3 aPos;
layout(location = 1) in mat4 aTransform;
layout(location = 5) in vec3 aColor;
layout(location = 6) in vec3 aNormal;

out vec3 fColor;
out vec3 fWorldPos;
out vec3 fNormal;

uniform mat4 projection;

void main() {
    vec4 worldPos = aTransform * vec4(aPos, 1.0f);
    fWorldPos = worldPos.xyz;
    fNormal = normalize(mat3(transpose(inverse(aTransform))) * aNormal);
    fColor = aColor;
    gl_Position = projection * worldPos;
}
