]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - shaders/3d/entity/vertex.glsl
a53f950549202299b36aa88050621e5e644ef104
[dragonblocks_alpha.git] / shaders / 3d / entity / vertex.glsl
1 layout(location = 0) in vec3 vertexPosition;
2 layout(location = 1) in vec3 vertexNormal;
3
4 out vec3 fragmentPosition;
5 out vec3 fragmentTextureCoordinates;
6 out float fragmentLight;
7
8 uniform mat4 model;
9 uniform mat4 VP;
10 uniform float daylight;
11 uniform float ambientLight;
12 uniform vec3 lightDir;
13
14 void main()
15 {
16         vec4 worldSpace = model * vec4(vertexPosition, 1.0);
17         gl_Position = VP * worldSpace;
18
19         fragmentPosition = worldSpace.xyz;
20         fragmentTextureCoordinates = vertexPosition;
21
22         mat3 normalMatrix = transpose(inverse(mat3(model)));
23         vec3 normal = normalize(normalMatrix * vertexNormal);
24         fragmentLight = ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);
25 }