2025-11-24 15:14:10 +00:00

31 lines
659 B
GLSL

#version 330 core
// --- INPUTS ---
layout(location = 0) in vec3 aPosition;
layout(location = 1) in vec3 aNormal;
layout(location = 2) in vec2 aTexCoord;
// --- OUTPUTS ---
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoord;
// --- UNIFORMS ---
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);
}