Do assignment 3
[opengl.git] / fragment.glsl
index e41a7f929083f43ba0ee3653e1cf37946eb9daf2..cffd8a01a0abcd4d11f2a708a2820e10b440209b 100644 (file)
@@ -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;
 }