#version 330 core out vec4 FragColor; in vec3 FragPos; in vec3 Normal; in vec2 TexCoord; uniform sampler2D texture1; uniform sampler2D texture2; uniform float mixAmount = 0.2; uniform vec3 lightPos; uniform vec3 viewPos; uniform vec3 lightColor = vec3(1.0); uniform float ambientStrength = 0.2; uniform float specularStrength = 0.5; uniform float shininess = 32.0; void main() { vec3 norm = normalize(Normal); vec3 lightDir = normalize(lightPos - FragPos); vec3 viewDir = normalize(viewPos - FragPos); // Ambient vec3 ambient = ambientStrength * lightColor; // Diffuse float diff = max(dot(norm, lightDir), 0.0); vec3 diffuse = diff * lightColor; // Specular (Blinn-Phong) vec3 halfwayDir = normalize(lightDir + viewDir); float spec = pow(max(dot(norm, halfwayDir), 0.0), shininess); vec3 specular = specularStrength * spec * lightColor; // Texture mixing (corrected) vec4 tex1 = texture(texture1, TexCoord); vec4 tex2 = texture(texture2, TexCoord); vec4 mixedTex = mix(tex1, tex2, mixAmount); vec3 texColor = mixedTex.rgb; vec3 result = (ambient + diffuse + specular) * texColor; FragColor = vec4(result, mixedTex.a); // Preserve alpha if needed }