basic lighting

This commit is contained in:
2025-11-27 11:37:56 +00:00
parent bb7a3bafd2
commit 25a54bab1b
6 changed files with 88 additions and 19 deletions

View File

@@ -3,8 +3,9 @@
layout(location = 0) in vec3 position; // Vertex position
layout(location = 1) in vec3 normal; // Vertex normal
layout(location = 2) in vec2 texCoord; // Vertex texture coordinate
out vec3 Color; // Output color to the fragment shader
out vec2 TexCoord; // Output texture coordinate to the fragment shader
out vec3 Normal;
out vec3 FragPos;
out vec2 TexCoord;
uniform mat4 model;
uniform mat4 view;
@@ -12,6 +13,7 @@ uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(position, 1.0); // Apply transformation matrices
Color = normal * 0.5 + 0.5; // Simple coloring based on normal
TexCoord = texCoord; // Pass through the texture coordinate
FragPos = vec3(model * vec4(position, 1.0));
Normal = mat3(transpose(inverse(model))) * normal;
TexCoord = texCoord;
}