feat: add Phong specular lighting to fragment shader with shininess and strength controls

This commit is contained in:
2025-10-02 13:24:06 +02:00
parent 3a138ec59e
commit 9c3795044a

View File

@@ -14,5 +14,13 @@ void main() {
vec3 diffuse = vColor.rgb * lambert;
// combine ambient and diffuse
vec3 result = ambient + diffuse;
// specular component (Phong)
float shininess = 32.0;
vec3 viewDir = vec3(0.0, 0.0, 1.0);
vec3 reflectDir = reflect(-lightDirection, normalize(vNormal));
float spec = pow(max(dot(reflectDir, viewDir), 0.0), shininess);
float specStrength = 0.5;
vec3 specular = specStrength * spec * vec3(1.0);
result += specular;
color = vec4(result, vColor.a);
}