// cube_vertex_shader.vs #version 330 core // Vertex Attributes layout(location = 0) in vec3 aPos; // Vertex position layout(location = 1) in vec3 aNormal; // Vertex normal layout(location = 2) in vec2 aTexCoords; // Texture coordinates // Uniform Matrices uniform mat4 model; uniform mat4 view; uniform mat4 projection; uniform mat4 lightSpaceMatrix; // Output to Fragment Shader out VS_OUT { vec3 FragPos; // Fragment position in world space vec3 Normal; // Fragment normal in world space vec2 TexCoords; // Texture coordinates vec4 FragPosLightSpace; // Fragment position in light space } fs_in; void main() { // Calculate fragment position in world space fs_in.FragPos = vec3(model * vec4(aPos, 1.0)); // Calculate and normalize the normal vector in world space fs_in.Normal = mat3(transpose(inverse(model))) * aNormal; // Pass through texture coordinates fs_in.TexCoords = aTexCoords; // Calculate fragment position in light space for shadow mapping fs_in.FragPosLightSpace = lightSpaceMatrix * vec4(fs_in.FragPos, 1.0); // Final vertex position in clip space gl_Position = projection * view * vec4(fs_in.FragPos, 1.0); }