Skip to content

Commit 9f54bea

Browse files
committed
No negative diffuse shading
The clamping on the lambert factor from the previous exercise (https://github.com/stackgl/shader-school/blob/master/exercises/light-2/shaders/fragment.glsl) wasn't done in this one.
1 parent e02964e commit 9f54bea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

exercises/light-3/shaders/fragment.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ void main() {
99
vec3 normal = normalize(fragNormal);
1010
vec3 light = normalize(lightDirection);
1111

12-
float lambert = dot(normal, light);
12+
float lambert = max(dot(normal, light), 0.0);
1313
float phong = pow(max(dot(reflect(light, normal), eyeDirection), 0.0), shininess);
1414

1515
vec3 lightColor = ambient + diffuse * lambert + specular * phong;
1616
gl_FragColor = vec4(lightColor, 1);
17-
}
17+
}

0 commit comments

Comments
 (0)