Fix diffuse lighting
This commit is contained in:
parent
a7396c71fe
commit
1a687a2f24
@ -39,7 +39,11 @@ void main() {
|
||||
|
||||
if (!material.unshaded) {
|
||||
vec3 ambient = directionalLight.ambient * directionalLight.color;
|
||||
vec3 diffuse = directionalLight.diffuse * reflect(directionalLight.direction, NORMAL) * directionalLight.color;
|
||||
FragColor *= vec4(ambient, 1.0);
|
||||
ambient = max(ambient, 0.0);
|
||||
|
||||
vec3 diffuse = directionalLight.diffuse * dot(directionalLight.direction, NORMAL) * directionalLight.color;
|
||||
diffuse = max(diffuse, 0.0);
|
||||
|
||||
FragColor *= vec4(ambient + diffuse, 1.0);
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ void main() {
|
||||
vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
|
||||
gl_Position = vertex;
|
||||
UV = vec3(uv * vertex.z, vertex.z);
|
||||
NORMAL = normal;
|
||||
NORMAL = (PROJECTION * VIEW * MODEL * vec4(normal, 0.0)).xyz;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user