More than 4 weights per vertex?

Hey everyone,

recenlty I wanted to get rid of the constraint that blender importer has when it loads mesh with armature.
When I load mesh that has vertices weights assigned I allow a maximum of 4 weight per vertex. It means that one vertex can be attached to a maximum of 4 bones.
Because there is no such constraint in blender I tried to create a weight and weight index buffers that allow more than 4 weight/indexes for a mesh’s vertex.

But I cannot create a VertexBuffer with more that 4 elements for a ;data block’ in the buffer.
The same happens when I add a ‘raw’ buffer with type to the mesh. I gess that mesh always transforms
the buffer into vertex buffer and then throws an exception when a single block of data has more than 4 elements.

Is there a way to avoid this exception ?

If I am not clear enough please let me know :wink:

Just leave out anything above the 4th modifier, play safe :wink: You rather have to think the other way around, I guess some of the limits in jme make sense for opengl rendering as the target.

Or loop all weights which assigned to a bone and remove all which have less values (like 0.001).
Or like Normen said…

1 Like

Or a combination of both :smiley: Good idea @mifth! ^^

@Kaelthas said: I gess that mesh always transforms the buffer into vertex buffer and then throws an exception when a single block of data has more than 4 elements.
I guess that's why this 4 bones per vertex limitation exists in the first place. This limitation is also useful for hardware skinning where each vertex bone weights and bone Index are passed as a vec4. If we have a random number of weight this is gonna be very tedious to handle.

@mifth way is the way to go. The 4 most weighted bones should be ok.

OK thanks for your suggestions :slight_smile:

I have just made a commit. Now if a vertex has more than 4 weights then the ‘strongest’ ones will be used.
And warning about such situation is logged only once and not for every vertex as it was before because it was pretty annoying and could really
increase the loading time.

Hope the changes will not break anything else XD

5 Likes

Nice @Kaelthas

What is the easiest way to get an overview of the vertexe and their weights? And to correct it.

If I understand the above post, someone wrote a python script for it. Can this be used generally or was it very specific to the model in question?

I know python but haven’t learnt to use it with Blender yet.

I tried loading my blend and the .j3o files in a text editor but they seem binary or hard to read. Gedit won’t take them.
I know how to check Vertex groups in Blender, but there must be some easier way to do this specifically?

I have a model that loads but warns for “more than 4 weights on some vertexes” and then I get some animation error, thought it could be related.

Can Blender be configured to assign max 4 weights to avoid this in the first place?
I use automatic weights for assigning this model to the armature so there’s nothing complicated with my groups.