28 lines
630 B
GLSL
28 lines
630 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;
|
|
|
|
void main()
|
|
{
|
|
vec4 pos = vec4(aPos, 1.0);
|
|
mat4x4 mvp = _Projection * _Model * _View;
|
|
|
|
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);
|
|
}
|