30 lines
693 B
GLSL
30 lines
693 B
GLSL
#version 330 core
|
|
|
|
layout (location = 0) in vec3 aPos;
|
|
layout (location = 1) in vec3 aNormal;
|
|
|
|
uniform mat4x4 _Model;
|
|
uniform mat4x4 _View;
|
|
uniform mat4x4 _Projection;
|
|
|
|
out vec3 Normal;
|
|
out vec3 FragPos;
|
|
out mat4x4 ModelViewProjection;
|
|
|
|
void main()
|
|
{
|
|
vec4 pos = vec4(aPos, 1.0);
|
|
mat4x4 mvp = _Projection * _View * _Model;
|
|
ModelViewProjection = mvp;
|
|
|
|
gl_Position = mvp * pos;
|
|
FragPos = vec3(_Model * pos);
|
|
|
|
// Convert the normal from model to world space
|
|
mat3 normalMatrix = mat3(mvp);
|
|
normalMatrix = inverse(normalMatrix);
|
|
normalMatrix = transpose(normalMatrix);
|
|
Normal = normalize(normalMatrix * aNormal);
|
|
//Normal = normalize(_Model * aNormal);
|
|
}
|