Sign in to follow this  

Bones weights

This topic is 828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I just have a simple question. I have an animated mesh and want to improve some animations in my framework. Actually each bone has two more influence bones. Thinking on it I feel it could be even more realistic if it should be weghted by at least four or five bones with each respective weights but how should I achieve that?

 

Actually my vertex declaration is:

D3DVERTEXELEMENT9 decl_skinning[] =
    {
        { 2,  0, D3DDECLTYPE_SHORT4     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES , 0 },
        { 2,  8, D3DDECLTYPE_FLOAT3     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT  , 0 },
        { 0,  0, D3DDECLTYPE_FLOAT3     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION     , 0 },
        { 0, 12, D3DDECLTYPE_FLOAT3     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL       , 0 },
        { 0, 24, D3DDECLTYPE_D3DCOLOR   , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR        , 0 },
        { 0, 28, D3DDECLTYPE_FLOAT2     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD     , 0 },

On the shader vertex side

struct VS_SKINNING
{
    int4    boneNdxs  : BLENDINDICES;
    float3  weights   : BLENDWEIGHT;
};

How should I do with such limitation?

 

Thanks in advance.

Edited by #Include Graphics

Share this post


Link to post
Share on other sites

5-6 bones? What are you making? A starfish?

 

Putting that aside, can't you just do:

struct VS_SKINNING
{
    int4    boneNdxs1  : BLENDINDICES1;
    int4    boneNdxs2  : BLENDINDICES2;
    float4  weights1   : BLENDWEIGHT1; //why was it float3?_?
    float4  weights2   : BLENDWEIGHT2;
};
D3DVERTEXELEMENT9 decl_skinning[] =
    {
        { 2,  0, D3DDECLTYPE_SHORT4     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES , 0 },
        { 2,  8, D3DDECLTYPE_SHORT4     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES , 1 },
        { 2,  16, D3DDECLTYPE_FLOAT4     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT  , 0 }, // I'm not sure why you had 3 weights but 4 indices
        { 2,  32, D3DDECLTYPE_FLOAT4     , D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT  , 1 }, // so I changed it to FLOAT4

?

Edited by Zaoshi Kaba

Share this post


Link to post
Share on other sites

haha okay, so I can index that semantic also as with TEXCOORD.

 

I am trying to make a human with so smooth and near hyper-realistic movements, my envelope has 60 bones so it is a bit hard to evaluate correctly the influences by only having two more influence bones.

 

The question is with that, Do you really think I am trying too high with 4 or 5 influence bones?. How many influences will be enough to have it really realistic?

 

In 3ds max you can have up to 20 bone influences smile.png

Edited by #Include Graphics

Share this post


Link to post
Share on other sites

I just can't think of a place where you would need so many influences.

Joints are usually only 2 influences, except for maybe fingers, toes, hip, neck, shoulders, etc. even in these cases 3 should be enough I believe.

Although I'm not an expert.

Share this post


Link to post
Share on other sites

I really appreciate that experience you shared smile.png

 

When you refer to dinamically is it about variable per bone or just about variable for all bones on runtime?

 

If it is variable per bone do you add another int in the vertex declaration for the number of influences for the current bone? I am trying to figure it out :D

Edited by #Include Graphics

Share this post


Link to post
Share on other sites

dx9 based code may have a 4 bone limit.  the sample code does, and mentions something about a limit as i recall. in fact, i just added dx9 skinned meshes to Caveman 3.0, and i suspect some of my models may have 5 weights - causing the occasional rare lockup or crash. but it may be controller related as well. i have yet to check into it. but do check the 4 bone limit. i'm not sure if its related to dx9 compatable cards, on a per card basis, depends on shader version, or what - but i do recall something about 4 bones max.

Share this post


Link to post
Share on other sites

en you refer to dinamically is it about variable per bone or just about variable for all bones on runtime?
 
If it is variable per bone do you add another int in the vertex declaration for the number of influences for the current bone? I am trying to figure it out

On Wii, every model was exported with 4 bones per vert, but then the LOD system decided how many that model-instance would use each frame.
If a model-instance was far enough away, it would just use the bone with the highest weightper vert. A little closer, it would use the two highest weighted bones, etc... Basically a different vertex program is chosen based on model LOD.

The most common system I've seen just processes either 4 or 8 bones per vert, and lots of verts have bones with zero weights.

The most recent system I worked with exported 5 bones for every vert, but then it grouped the verts by the number of non-zero weighted bones. i.e. You'd have a bucket of verts that you knew used all 5 of it's bones, a bucket that only used the first 3, a bucket that only used the first 2, etc... A different program was run over each bucket to produce the final animated verts for that frame.



i suspect some of my models may have 5 weights - causing the occasional rare lockup or crash

When importing the mesh, for each vert, you need to sort the influecing bones by weight and then only keep the first N bones. If you've got less than N bones you need to duplicate an existing one but give it zero weight until you do have N bones.
Most dx9 games do use N=4 because storing 4 bone indices and 4 weights inside two "byte4" vertex attributes fits very well. But shaders are completely programmable so you can easily do 2 or 8 or any other number you like.

Share this post


Link to post
Share on other sites

When importing the mesh, for each vert, you need to sort the influecing bones by weight and then only keep the first N bones. If you've got less than N bones you need to duplicate an existing one but give it zero weight until you do have N bones.

 

hmm...

 

i'll have to check the microsoft code from tiny.cpp.  i think i recall them doing something like making sure the weights sum to 1.0. but i'm not sure if they sort by weight or not, or whether they force everything to have N bones. i remember it can handle 1,2,3, or 4 bones, but i think that's on a per model or per mesh container or per mesh basis, it couldn't be on a per vertex basis. i think it decides a model or mesh container is 1,2,3 or 4 bones, and then assumes all the data that follows is of that format.

 

when rigging in blender, i just used automatic weights, with little or no checking or cleanup in weight paint - juts to get something up and running quickly. so i was thinking it might be possible that more than four bones got assigned to some vertex somewhere.

 

just this morning i finally got a save game that most of the time can reproduce the crash i mentioned . its related to drawing NPCs involved in a partially offscreen combat with other NPCs.  i've put a file trace on it.  the next trace run should confirm that its D3DXAnimationController->AdvanceTime() that crashes. so it looks like its a bad animation controller pointer. probably one of the NPCs dies, and the dead ani doesn't get set, or the dead ani is missing from some model's .x file - something like that.  so its not the microsoft code, its my use of an invalid animation controller. and its not related to a four bone limit in dx9 skinned meshes.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

This topic is 828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this