#version 330 core // Vertex shader decides where each vertex is in 3D space // --- INPUTS --- // Comes directly from the vertex buffer layout(location = 0) in vec3 aPosition; // Raw 3D position layout(location = 1) in vec3 aNormal; // The direction perpendicular to the surface layout(location = 2) in vec2 aTexCoord; // The U,V texture coordinates // --- OUTPUTS --- // We can pass data to the fragment shader through these out vec3 FragPos; out vec3 Normal; out vec2 TexCoord; // --- UNIFORMS --- // These are matrices that help transform our vertices uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main(void) { // 1. Calculate World Position FragPos = vec3(model * vec4(aPosition, 1.0)); // 2. Calculate Normal Normal = mat3(transpose(inverse(model))) * aNormal; // 3. Pass Texture Coordinates TexCoord = aTexCoord; // 4. Calculate Final Position gl_Position = projection * view * vec4(FragPos, 1.0); }