Fix how loading works before clenaup.
This commit is contained in:
parent
6d21b7f163
commit
a629e16fe2
7 changed files with 19 additions and 15 deletions
|
|
@ -6,6 +6,7 @@ layout (location = 3) in vec3 aTangent;
|
|||
layout (location = 4) in vec3 aBitangent;
|
||||
layout (location = 5) in ivec4 boneIds;
|
||||
layout (location = 6) in vec4 weights;
|
||||
layout (location = 7) in int bone_count;
|
||||
|
||||
out vec3 FragPos;
|
||||
out vec3 Normal;
|
||||
|
|
@ -20,26 +21,30 @@ uniform mat4 lightSpaceMatrix;
|
|||
uniform bool hasBones;
|
||||
|
||||
const int MAX_BONES = 100;
|
||||
const int MAX_BONE_INFLUENCE = 4;
|
||||
uniform mat4 finalBonesMatrices[MAX_BONES];
|
||||
|
||||
vec4 AnimateBones() {
|
||||
vec4 totalPosition = vec4(0.0f);
|
||||
for(int i = 0; i < MAX_BONE_INFLUENCE; i++) {
|
||||
if(boneIds[i] == -1) continue;
|
||||
|
||||
if(boneIds[i] >= MAX_BONES) {
|
||||
for(int i = 0; i < bone_count; i++) {
|
||||
int bone_id = boneIds[i];
|
||||
|
||||
if(bone_id >= MAX_BONES) {
|
||||
totalPosition = vec4(aPos, 1.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
int bone_id = boneIds[i];
|
||||
// bone found, mark it
|
||||
vec4 localPosition = finalBonesMatrices[bone_id] * vec4(aPos, 1.0f);
|
||||
totalPosition += localPosition * weights[i];
|
||||
vec3 localNormal = mat3(finalBonesMatrices[boneIds[i]]) * aNormal;
|
||||
vec3 localNormal = mat3(finalBonesMatrices[bone_id]) * aNormal;
|
||||
}
|
||||
|
||||
return totalPosition;
|
||||
if(totalPosition == vec4(0.0f)) {
|
||||
return vec4(aPos, 1.0f);
|
||||
} else {
|
||||
return totalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue