Open SingingOn opened 2 years ago
I am using a Linux OS and my build method and codes are different from here so I can't open a PR. This is my solution,
diff a/anim_model.vs b/anim_model.vs
6,7c6,7
< layout(location = 3) in ivec4 boneIds;
< layout(location = 4) in vec4 weights;
---
> layout(location = 5) in ivec4 boneIds;
> layout(location = 6) in vec4 weights;
diff a/skeletal_animation.cpp b/skeletal_animation.cpp
9c10
< #include <learnopengl/shader_m.h>
---
> #include <learnopengl/shader.h>
127c128
< auto transforms = animator.GetPoseTransforms();
---
> auto transforms = animator.GetFinalBoneMatrices();
129c130
< ourShader.setMat4("finalBonesTransformations[" + std::to_string(i) + "]", transforms[i]);
---
> ourShader.setMat4("finalBonesMatrices[" + std::to_string(i) + "]", transforms[i]);
someone test this and fix the skeletal_animation
Thanks a lot. I am using OSX system. I changed the codes after your suggestions, but I still cant see any animation. I checked my codes, perhaps it
s my lower opengl dirver(#version 410 core) under OSX.
hi @SingingOn, I meet the same problem with you, can't see any animation. Do you have fixed that?
@SingingOn hi,the problem has be resolved,it shows the same animation finally. It does not matter with #version。
correct result:
There are several mistakes: in vertex shader ani_model,uniform names not match the definations in c++. The code below can run successfully!!
#version 330 core
layout(location = 0) in vec3 pos;
layout(location = 1) in vec3 norm;
layout(location = 2) in vec2 tex;
layout(location = 3) in vec3 tangent;
layout(location = 4) in vec3 bitangent;
layout(location = 5) in ivec4 boneIds;
layout(location = 6) in vec4 weights;
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
const int MAX_BONES = 100;
const int MAX_BONE_INFLUENCE = 4;
uniform mat4 finalBonesMatrices[MAX_BONES];
out vec2 TexCoords;
void main()
{
vec4 totalPosition = vec4(0.0f);
for(int i = 0 ; i < MAX_BONE_INFLUENCE ; i++)
{
if(boneIds[i] == -1)
continue;
if(boneIds[i] >=MAX_BONES)
{
totalPosition = vec4(pos,1.0f);
break;
}
vec4 localPosition = finalBonesTransformations[boneIds[i]] * vec4(pos,1.0f);
totalPosition += localPosition * weights[i];
vec3 localNormal = mat3(finalBonesMatrices[boneIds[i]]) * norm;
}
mat4 viewModel = view * model;
gl_Position = projection * viewModel * totalPosition;
TexCoords = tex;
}
@IC-Tech , @summer-go , I can see the animations now, thank you very much.
skeletal_animation.cpp, auto transforms = animator.GetPoseTransforms(); The function "GetPoseTransforms" is undefined in Animator class.