raylib/examples/resources/shaders/phong.vs

29 lines
669 B
Plaintext
Raw Normal View History

#version 330
// Vertex input data
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec3 vertexNormal;
// Projection and model data
2016-01-13 19:13:28 +03:00
uniform mat4 mvpMatrix;
2016-01-25 15:39:23 +03:00
uniform mat4 modelMatrix;
2016-01-25 15:39:23 +03:00
//uniform mat4 viewMatrix; // Not used
// Attributes to fragment shader
out vec2 fragTexCoord;
out vec3 fragNormal;
void main()
{
// Send texture coord to fragment shader
fragTexCoord = vertexTexCoord;
// Calculate view vector normal from model
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
2016-01-16 14:52:55 +03:00
fragNormal = normalize(normalMatrix*vertexNormal);
// Calculate final vertex position
2016-01-16 14:52:55 +03:00
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
}