feat: add Phong specular lighting to fragment shader with shininess and strength controls
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user