-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.vert
46 lines (33 loc) · 1018 Bytes
/
player.vert
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
44
45
46
#version 330 core
layout(location = 0) in vec3 pos;
layout(location = 1) in vec2 tex;
layout(location = 2) in vec3 normal;
layout(location = 3) in vec3 tangent;
layout(location = 4) in vec3 bitangent;
uniform mat4 MVP;
uniform mat4 model;
#define NR_POINT_LIGHTS 8
struct PointLight {
vec3 position;
vec3 color;
};
uniform PointLight pointLights[NR_POINT_LIGHTS];
out vec2 uv;
out vec3 tangentFragPos;
out PointLight tangentLights[NR_POINT_LIGHTS];
void main()
{
// texture stuff
uv = tex;
// to tangent space for bumpmap
vec3 T = normalize(vec3(model * vec4(tangent, 0.0)));
vec3 B = normalize(vec3(model * vec4(bitangent, 0.0)));
vec3 N = normalize(vec3(model * vec4(normal, 0.0)));
mat3 TBN = transpose(mat3(T, B, N));
tangentFragPos = TBN * vec3(model * vec4(pos, 1.0));
for(int i = 0; i < NR_POINT_LIGHTS; i++){
tangentLights[i].position = TBN * pointLights[i].position;
tangentLights[i].color = pointLights[i].color;
}
gl_Position = MVP * model * vec4(pos, 1.0);
}