Fix colors

This commit is contained in:
Tristan Daniël Maat 2022-08-12 22:59:26 +01:00
parent 63e062596c
commit e64644e0af
Signed by: tlater
GPG key ID: 49670FD774E43268

View file

@ -1,11 +1,11 @@
#version 300 es
//VERTEX SHADER
// VERTEX SHADER
//
// Takes vertices of a unit cube, scales them up along Y according to
// aHeight, and colors them with basic diffuse shading.
// Takes vertices of a unit cube, scales them up along Y according to
// aHeight, and colors them with basic diffuse shading.
#define CLEAR_COLOR vec4(0.0, 0.0, 0.0, 1.0)
#define BASE_COLOR vec4(1.0, 1.0, 1.0, 1.0)
#define BASE_COLOR vec3(0.6, 0.819607843137, 0.807843137255)
#define AMBIENT_LIGHT vec3(0.3, 0.3, 0.3)
#define LIGHT_DIRECTION normalize(vec3(0.85, 0.8, 0.75))
#define LIGHT_COLOR vec3(1.0, 1.0, 1.0)
@ -44,6 +44,9 @@ void main() {
vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
float directionalLight =
max(dot(transformedNormal.xyz, LIGHT_DIRECTION), 0.0);
vColor = vec4(directionalLight * LIGHT_COLOR + AMBIENT_LIGHT, 1.0);
vec3 appliedColor =
BASE_COLOR * (directionalLight * LIGHT_COLOR + AMBIENT_LIGHT);
vColor = vec4(appliedColor.rgb, 1.0);
}
}