X-Git-Url: https://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=fragment.glsl;fp=fragment.glsl;h=cffd8a01a0abcd4d11f2a708a2820e10b440209b;hp=e41a7f929083f43ba0ee3653e1cf37946eb9daf2;hb=5a4d005b668b98d44ef20391ecddaf6bfc2ee70f;hpb=c5d984e4904ae7b286bf095a1c640cc25cebe9be diff --git a/fragment.glsl b/fragment.glsl index e41a7f9..cffd8a0 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -4,17 +4,20 @@ in vec3 normal; in vec3 fragPos; uniform vec3 lightPos; uniform vec3 viewPos; +uniform vec4 lightColor; out vec4 FragColor; void main() { float ambient = 0.1; float specularStrength = 0.5; vec3 lightDir = normalize(fragPos - lightPos); - float diffuse = max(0, dot(normal, lightDir)); + float diffuse = max(0, dot(-normal, lightDir)); vec3 viewDir = normalize(fragPos - viewPos); vec3 reflectDir = reflect(-lightDir, normal); float specular = pow(max(0, dot(viewDir, reflectDir)), 128); - FragColor = (ambient + diffuse + specular) * color; + vec4 lighting = (ambient + diffuse + specular) * lightColor; + + FragColor = lighting * color; }