68 lines
1.8 KiB
GLSL
68 lines
1.8 KiB
GLSL
//Vertex Shader
|
|
#version 430 core
|
|
|
|
|
|
|
|
|
|
layout (location = 0) in vec3 aPos;
|
|
layout (location = 1) in vec3 aNormal;
|
|
layout (location = 2) in vec4 aWeights;
|
|
layout (location = 3) in ivec4 aIndex;
|
|
|
|
|
|
|
|
uniform mat4 transform;
|
|
uniform mat4 model;
|
|
uniform mat4 view;
|
|
uniform mat4 projection;
|
|
|
|
|
|
const int MAX_BONES = 100;
|
|
uniform mat4 bones[MAX_BONES];
|
|
uniform int hasBones;
|
|
uniform int numBones;
|
|
|
|
|
|
|
|
out vec3 Normal;
|
|
out vec3 FragPos;
|
|
out vec2 TexCoords;
|
|
|
|
|
|
|
|
void main()
|
|
{
|
|
if(hasBones == 1){
|
|
//mat4 BoneTransform;
|
|
//for(int i = 0; i < MAX_BONES; i++){
|
|
// if(i < numBones){
|
|
// BoneTransform += bones[i] * aWeights[i];
|
|
// }
|
|
//}
|
|
mat4 BoneTransform;
|
|
BoneTransform = mat4(
|
|
1.0,0.0,0.0,0.0,
|
|
0.0,1.0,0.0,0.0,
|
|
0.0,0.0,1.0,0.0,
|
|
0.0,0.0,0.0,1.0);
|
|
//BoneTransform = BoneTransform * mat4(
|
|
// 1.0,0.0,0.0,0.0,
|
|
// 0.0,1.0,0.0,0.0,
|
|
// 0.0,0.0,2.0,0.0,
|
|
// 0.0,0.0,0.0,1.0);
|
|
BoneTransform = BoneTransform * bones[aIndex[0]] * aWeights[0];
|
|
BoneTransform += BoneTransform * bones[aIndex[1]] * aWeights[1];
|
|
BoneTransform += BoneTransform * bones[aIndex[2]] * aWeights[2];
|
|
BoneTransform += BoneTransform * bones[aIndex[3]] * aWeights[3];
|
|
//BoneTransform += bones[aIndex[0]] * 1.0;
|
|
//BoneTransform += bones[aIndex[1]] * aWeights[1];
|
|
//BoneTransform += bones[aIndex[2]] * aWeights[2];
|
|
//BoneTransform += bones[aIndex[3]] * aWeights[3];
|
|
gl_Position = projection * view * model * BoneTransform * vec4(aPos, 1.0);
|
|
} else {
|
|
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
|
}
|
|
FragPos = vec3(model * vec4(aPos, 1.0));
|
|
Normal = vec3(vec4(aNormal, 1.0));
|
|
TexCoords = vec2(0.5, 0.5);
|
|
} |