42 lines
1.1 KiB
GLSL
42 lines
1.1 KiB
GLSL
#version 430
|
|
|
|
layout (location = 0) in vec3 aPos;
|
|
layout (location = 1) in vec3 aNormal;
|
|
layout (location = 2) in vec2 aTexCoords;
|
|
layout (location = 3) in vec3 aTangent;
|
|
layout (location = 4) in vec3 aBitangent;
|
|
|
|
out VS_OUT {
|
|
vec3 FragPos;
|
|
vec4 FragPosLightSpace;
|
|
vec2 TexCoords;
|
|
vec3 TangentLightDir;
|
|
vec3 TangentViewPos;
|
|
vec3 TangentFragPos;
|
|
} vs_out;
|
|
|
|
uniform mat4 projection;
|
|
uniform mat4 view;
|
|
uniform mat4 model;
|
|
|
|
uniform vec3 light_direction;
|
|
uniform mat4 light_space_matrix;
|
|
|
|
uniform vec3 viewPos;
|
|
|
|
void main() {
|
|
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
|
vs_out.FragPos = vec3(model * vec4(aPos, 1.0));
|
|
vs_out.TexCoords = aTexCoords;
|
|
vs_out.FragPosLightSpace = light_space_matrix * vec4(vs_out.FragPos, 1.0);
|
|
|
|
vec3 T = normalize(mat3(model) * aTangent);
|
|
vec3 B = normalize(mat3(model) * aBitangent);
|
|
vec3 N = normalize(mat3(model) * aNormal);
|
|
mat3 TBN = transpose(mat3(T, B, N));
|
|
|
|
vs_out.TangentLightDir = light_direction;
|
|
vs_out.TangentViewPos = TBN * viewPos;
|
|
vs_out.TangentFragPos = TBN * vs_out.FragPos;
|
|
}
|