31 lines
688 B
GLSL
31 lines
688 B
GLSL
#version 330
|
|
|
|
// Input vertex attributes
|
|
in vec3 vertexPosition;
|
|
in vec3 vertexNormal;
|
|
in vec2 vertexTexCoord;
|
|
|
|
// Uniforms
|
|
uniform mat4 mvp;
|
|
uniform mat4 matModel;
|
|
uniform mat4 matNormal;
|
|
|
|
// Output to fragment shader
|
|
out vec3 fragPosition;
|
|
out vec3 fragNormal;
|
|
out vec2 fragTexCoord;
|
|
|
|
void main()
|
|
{
|
|
// Transform vertex position to world space
|
|
fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
|
|
|
|
// Transform normal to world space
|
|
fragNormal = normalize(vec3(matNormal * vec4(vertexNormal, 0.0)));
|
|
|
|
// Pass texture coordinates
|
|
fragTexCoord = vertexTexCoord;
|
|
|
|
// Transform to clip space
|
|
gl_Position = mvp * vec4(vertexPosition, 1.0);
|
|
}
|