1 layout(location = 0) in vec3 vertexPosition;
2 layout(location = 1) in vec3 vertexNormal;
3 layout(location = 2) in vec3 vertexColor;
5 out vec3 fragmentPosition;
6 out vec3 fragmentColor;
10 uniform float daylight;
11 uniform float ambientLight;
12 uniform vec3 lightDir;
16 vec4 worldSpace = model * vec4(vertexPosition, 1.0);
17 gl_Position = VP * worldSpace;
19 fragmentPosition = worldSpace.xyz;
20 fragmentColor = vertexColor;
22 mat3 normalMatrix = transpose(inverse(mat3(model)));
23 vec3 normal = normalize(normalMatrix * vertexNormal);
24 fragmentColor *= ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);