Tesseract-Engine/assets/shaders/UnlitMaterial.vert

33 lines
1.1 KiB
GLSL
Raw Normal View History

#version 330 core
layout(location = 0) in vec3 aPos; // Vertex position
layout(location = 1) in vec2 aTexCoord; // Texture coordinate
layout(location = 2) in vec3 aNormal; // Vertex normal
2025-01-01 19:04:56 +00:00
uniform mat4 uMVP; // Model-View-Projection matrix
uniform mat4 uModel; // Model matrix
uniform mat4 uLightSpaceMatrix; // Light space matrix
2025-01-01 19:04:56 +00:00
out vec2 TexCoord; // Passed to fragment shader
out vec3 Normal; // Passed to fragment shader
out vec3 FragPos; // Passed to fragment shader
out vec4 FragPosLightSpace; // Passed to fragment shader
void main()
{
// Compute the fragment position in world space
FragPos = vec3(uModel * vec4(aPos, 1.0));
2025-01-01 19:04:56 +00:00
// Transform the normal vector
Normal = mat3(transpose(inverse(uModel))) * aNormal;
2025-01-01 19:04:56 +00:00
// Pass through the texture coordinate
TexCoord = aTexCoord;
2025-01-01 19:04:56 +00:00
// Transform the fragment position to light space
FragPosLightSpace = uLightSpaceMatrix * vec4(FragPos, 1.0);
// Final vertex position
gl_Position = uMVP * vec4(aPos, 1.0);
}