A WIP 3D game engine in C++ using OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
990 B

#version 330 core
layout (location = 0) in vec3 aVertexPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
layout (location = 4) in vec3 aTangent;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform bool skyboxON;
out vec3 Normal;
out vec3 FragPos;
out vec3 theTexCoord;
out mat3 TBN;
void main()
{
gl_Position = projection * view * model * vec4( aVertexPos, 1.0);
if (skyboxON) {
theTexCoord = aVertexPos;
FragPos = aVertexPos; // vec3(model * vec4(aVertexPos, 1.0));
return;
}
// calculating TBN
vec3 T = normalize(vec3(model * vec4(aTangent, 0.0)));
vec3 N = normalize(vec3(model * vec4(aNormal, 0.0)));
T = normalize(T - dot(T, N) * N);
vec3 B = cross(N,T);
TBN = mat3(T, B, N);
// calculating normal
theTexCoord = vec3(aTexCoords, 1.0);
Normal = mat3(transpose(inverse(model))) * aNormal;
FragPos = vec3(model * vec4(aVertexPos, 1.0));
}