skein/vert.glsl

28 lines
630 B
Plaintext
Raw Permalink 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;
2023-07-31 23:30:35 +02:00
void main()
{
2023-08-03 10:26:01 +02:00
vec4 pos = vec4(aPos, 1.0);
mat4x4 mvp = _Projection * _Model * _View;
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);
}