Add a brewfile
[opengl.git] / pbrvert.glsl
1 #version 330
2 in vec3 pos;
3 in vec3 unscaledNormal;
4 in vec2 vTexCoord;
5
6 in ivec4 boneIds;
7 in vec4 boneWeights;
8
9 uniform mat4 model;
10 uniform mat4 view;
11 uniform mat4 projection;
12
13 uniform mat4 bones[16 + 1];
14
15 out vec3 normal;
16 out vec2 texCoords;
17
18 out vec3 lightPos, viewPos, worldPos;
19
20 void main() {
21         texCoords = vTexCoord;
22
23         mat4 boneTrans = bones[boneIds.x] * boneWeights.x;
24         boneTrans += bones[boneIds.y] * boneWeights.y;
25         boneTrans += bones[boneIds.z] * boneWeights.z;
26         boneTrans += bones[boneIds.w] * boneWeights.w;
27
28         mat4 bonedModel = model * boneTrans;
29
30         worldPos = vec3(bonedModel * vec4(pos, 1.f));
31
32         normal = mat3(transpose(inverse(bonedModel))) * unscaledNormal;
33         
34         gl_Position = projection * view * bonedModel * vec4(pos, 1.f);
35 }
36