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

37 lines
871 B
GLSL

#version 330 core
out vec4 outputColor;
// --- INPUTS ---
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoord;
// --- UNIFORMS ---
uniform sampler2D uTexture;
void main()
{
// Lighting Setup
vec3 lightPos = vec3(1.2f, 1.0f, 2.0f);
vec3 lightColor = vec3(1.0f, 1.0f, 1.0f);
// 1. Get Texture Color (Keep it as vec4!)
vec4 objColor = texture(uTexture, TexCoord);
// 2. Ambient
float ambientStrength = 0.1f;
vec3 ambient = ambientStrength * lightColor;
// 3. Diffuse
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
float diff = max(dot(norm, lightDir), 0.0f);
vec3 diffuse = diff * lightColor;
// 4. Combine
// Note: We use objColor.rgb (vec3) to match the lighting calculation
vec3 result = (ambient + diffuse) * objColor.rgb;
outputColor = vec4(result, objColor.a);
}