2024-12-25 21:44:33 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2024-12-31 08:40:23 +00:00
|
|
|
layout(location = 0) in vec3 aPos; // Vertex position
|
|
|
|
layout(location = 1) in vec2 aTexCoord; // Texture coordinate
|
|
|
|
layout(location = 2) in vec3 aNormal; // Vertex normal
|
2024-12-25 21:44:33 +00:00
|
|
|
|
2024-12-30 04:25:16 +00:00
|
|
|
uniform mat4 uMVP; // Model-View-Projection matrix
|
|
|
|
uniform mat4 uModel; // Model matrix
|
2024-12-25 21:44:33 +00:00
|
|
|
|
2024-12-31 08:40:23 +00:00
|
|
|
out vec2 TexCoord; // Passed to fragment shader
|
|
|
|
out vec3 Normal; // Passed to fragment shader
|
|
|
|
out vec3 FragPos; // Passed to fragment shader
|
2024-12-25 21:44:33 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2024-12-31 08:40:23 +00:00
|
|
|
// Compute the fragment position in world space
|
|
|
|
FragPos = vec3(uModel * vec4(aPos, 1.0));
|
2024-12-30 04:25:16 +00:00
|
|
|
|
2024-12-31 08:40:23 +00:00
|
|
|
// Transform the normal vector
|
|
|
|
Normal = mat3(transpose(inverse(uModel))) * aNormal;
|
2024-12-30 04:25:16 +00:00
|
|
|
|
2024-12-31 08:40:23 +00:00
|
|
|
// Pass through the texture coordinate
|
|
|
|
TexCoord = aTexCoord;
|
2024-12-30 06:51:58 +00:00
|
|
|
|
2024-12-31 08:40:23 +00:00
|
|
|
// Final vertex position
|
|
|
|
gl_Position = uMVP * vec4(aPos, 1.0);
|
2024-12-25 21:44:33 +00:00
|
|
|
}
|