skein/vert.glsl

30 lines
693 B
Plaintext
Raw Normal View History

#version 330 core
layout (location = 0) in vec3 aPos;
2023-08-03 10:26:01 +02:00
layout (location = 1) in vec3 aNormal;
2023-08-03 10:26:01 +02:00
uniform mat4x4 _Model;
uniform mat4x4 _View;
uniform mat4x4 _Projection;
out vec3 Normal;
out vec3 FragPos;
out mat4x4 ModelViewProjection;
2023-07-31 23:30:35 +02:00
void main()
{
2023-08-03 10:26:01 +02:00
vec4 pos = vec4(aPos, 1.0);
2023-08-13 22:57:05 +02:00
mat4x4 mvp = _Projection * _View * _Model;
ModelViewProjection = mvp;
2023-08-03 10:26:01 +02:00
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);
}