Skip to content

Commit 80fa49d

Browse files
author
Spongman
committed
fix directionalLight direction sense
1 parent c572f6f commit 80fa49d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/webgl/shaders/light.vert

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void main(void){
5050
for (int j = 0; j < 8; j++) {
5151
if (uDirectionalLightCount == j) break;
5252
vec3 dir = uLightingDirection[j];
53-
float directionalLightWeighting = max(dot(vertexNormal, dir), 0.0);
53+
float directionalLightWeighting = max(dot(vertexNormal, -dir), 0.0);
5454
directionalLightFactor += uDirectionalColor[j] * directionalLightWeighting;
5555
}
5656

src/webgl/shaders/phong.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ float phongSpecular(
4646
float lambertDiffuse(
4747
vec3 lightDirection,
4848
vec3 surfaceNormal) {
49-
return max(0.0, dot(lightDirection, surfaceNormal));
49+
return max(0.0, dot(-lightDirection, surfaceNormal));
5050
}
5151

5252
LightResult light(vec3 lightVector) {

0 commit comments

Comments
 (0)