2015-12-21 19:25:22 +03:00
|
|
|
#version 330
|
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input vertex attributes
|
2015-12-21 19:25:22 +03:00
|
|
|
in vec3 vertexPosition;
|
|
|
|
in vec2 vertexTexCoord;
|
|
|
|
in vec3 vertexNormal;
|
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input uniform values
|
2016-01-13 19:13:28 +03:00
|
|
|
uniform mat4 mvpMatrix;
|
2015-12-21 19:25:22 +03:00
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Output vertex attributes (to fragment shader)
|
2015-12-21 19:25:22 +03:00
|
|
|
out vec2 fragTexCoord;
|
|
|
|
out vec3 fragNormal;
|
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// NOTE: Add here your custom variables
|
|
|
|
uniform mat4 modelMatrix;
|
|
|
|
|
2015-12-21 19:25:22 +03:00
|
|
|
void main()
|
|
|
|
{
|
2016-05-18 13:04:27 +03:00
|
|
|
// Send vertex attributes to fragment shader
|
2015-12-21 19:25:22 +03:00
|
|
|
fragTexCoord = vertexTexCoord;
|
2016-05-18 13:04:27 +03:00
|
|
|
|
2015-12-21 19:25:22 +03:00
|
|
|
// Calculate view vector normal from model
|
|
|
|
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
|
2016-01-13 19:13:28 +03:00
|
|
|
fragNormal = normalize(normalMatrix*vertexNormal);
|
2015-12-21 19:25:22 +03:00
|
|
|
|
|
|
|
// Calculate final vertex position
|
2016-01-13 19:13:28 +03:00
|
|
|
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
2015-12-21 19:25:22 +03:00
|
|
|
}
|