-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvertex.glsl
More file actions
43 lines (33 loc) · 1014 Bytes
/
Copy pathvertex.glsl
File metadata and controls
43 lines (33 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#version 450 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoord;
layout (location = 3) in vec3 aTangent;
layout (location = 4) in vec3 aBitangent;
out VS_OUT {
vec2 uv_coord;
vec3 frag_pos;
vec3 tangent_light;
vec3 tangent_view;
vec3 tangent_frag;
} vs_out;
uniform vec3 viewPos;
uniform vec3 lightPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
vs_out.frag_pos = vec3(model * vec4(aPos, 1.0));
vs_out.uv_coord = aTexCoord;
mat3 normalMat = transpose(inverse(mat3(model)));
vec3 T = normalize(normalMat * aTangent);
vec3 N = normalize(normalMat * aNormal);
T = normalize(T - dot(T, N) * N);
vec3 B = cross(N, T);
mat3 TBN = transpose(mat3(T, B, N));
vs_out.tangent_frag = TBN * vs_out.frag_pos;
vs_out.tangent_view = TBN * viewPos;
vs_out.tangent_light = TBN * lightPos;
gl_Position = projection * view * model * vec4(aPos, 1.0);
}