opengl – How do I calculate the shader to right the joints within the animation?

opengl – How do I calculate the shader to right the joints within the animation?

[ad_1]

For a while now I’ve been making an attempt to do skeleton animation utilizing Rust and OpenGL, I loaded the animation data appropriately, the bone ids and the affect weights, nonetheless I used to be unable to use the animation to the 100% right mannequin.

The screenshot under is the furthest I may get from making the animation look right, the issue is that if you happen to get shut… You’ll be able to see that between the transition from bone to bone, the joints with a higher deformation stop the lighting is ideal on the character’s pores and skin, making a slight doll-like sensation wherein the joints spotlight the skeleton:
enter image description here

This occurs as a result of the code I used within the shader is mainly this the place I solely use the primary transformation within the mannequin:

// Animation
vec4 tp = vec4(pos,1);
tp = CORRECAO[int(ossosid[0])]*tp;
tp = (ANIMACAO[int(ossosid[0])]*tp);
tp.xyz += ANIMACAO2[int(ossosid[0])];
// Neglect that half, that is simply because the animation is scaled to look on the display screen...
// It is not a part of the animation calculation.
pos = tp.xyz/50;

When I attempt to observe examples wherein I exploit affect weights… It is not working, extra particularly I can provide code examples and present the way it’s not working:

enter image description here

When I attempt to swap to calculation:

vec4 tp = vec4(pos,1);
tp = CORRECAO[int(ossosid[0])]*tp;
tp = (ANIMACAO[int(ossosid[0])]*tp)*pesos[0] + (ANIMACAO[int(ossosid[1])]*tp)*pesos[1];
tp.xyz += ANIMACAO2[int(ossosid[0])]*pesos[0] + ANIMACAO2[int(ossosid[1])]*pesos[1];
pos = tp.xyz/50;

Completely distorted when:

enter image description here

Utilizing:

vec4 tp = vec4(pos,1);
vec4 tp0 = CORRECAO[int(ossosid[0])]*tp;
tp0 = (ANIMACAO[int(ossosid[0])]*tp0)*pesos[0];
tp0.xyz += ANIMACAO2[int(ossosid[0])];
vec4 tp1 = CORRECAO[int(ossosid[1])]*tp;
tp1 = (ANIMACAO[int(ossosid[1])]*tp1)*pesos[1];
tp1.xyz += ANIMACAO2[int(ossosid[1])];
pos = tp0.xyz+tp1.xyz;
pos = pos.xyz/50;

One other:

enter image description here

vec4 tp = vec4(pos,1);
tp = (CORRECAO[int(ossosid[0])]*tp)*pesos[0];
tp = (ANIMACAO[int(ossosid[0])]*tp);
tp.xyz += ANIMACAO2[int(ossosid[0])]*pesos[0];
tp = (CORRECAO[int(ossosid[1])]*tp)*pesos[1];
tp = (ANIMACAO[int(ossosid[1])]*tp);
tp.xyz += ANIMACAO2[int(ossosid[1])]*pesos[1];
pos = tp.xyz/50;

Only one extra:

enter image description here

vec4 tp = vec4(pos,1);
tp = (CORRECAO[int(ossosid[0])]*tp);
tp = (ANIMACAO[int(ossosid[0])]*tp)*pesos[0]+(ANIMACAO[int(ossosid[1])]*tp)*pesos[1];
tp.xyz += ANIMACAO2[int(ossosid[0])];
pos = tp.xyz/50;

In different phrases… I can not make elbows, knees, shoulders, leg connections and hips as easy as I can do every little thing else… Particularly, know that: CORRECAO is the inverse bind matrix, ANIMACAO is the variable that rotates the purpose and ANIMACAO2 is the place of the purpose within the animation.

My query is how do I make the joints on the mannequin look easy? How do I apply this within the vertex shader?

P.S.: For all intents and functions, the animated mannequin is right here: hyperlink

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply