Fix diffuse lighting
This commit is contained in:
parent
8fb29d389a
commit
96f1e23a54
@ -39,7 +39,11 @@ void main() {
|
|||||||
|
|
||||||
if (!material.unshaded) {
|
if (!material.unshaded) {
|
||||||
vec3 ambient = directionalLight.ambient * directionalLight.color;
|
vec3 ambient = directionalLight.ambient * directionalLight.color;
|
||||||
vec3 diffuse = directionalLight.diffuse * reflect(directionalLight.direction, NORMAL) * directionalLight.color;
|
ambient = max(ambient, 0.0);
|
||||||
FragColor *= vec4(ambient, 1.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);
|
vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
|
||||||
gl_Position = vertex;
|
gl_Position = vertex;
|
||||||
UV = vec3(uv * vertex.z, vertex.z);
|
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