PDA

View Full Version : Automatic Weighting Tools?


kogen
05-02-2009, 05:20 PM
Hi guys and gals,

I'm about to create an automatic tool for weighting vertices in MXS.
It's not perfect at the moment, but before I make the same mistake twice creating a script that already exists I wanted to question here, if anyone knows a script that automatically weights vertices according to their position or distances to their bones???

Anyways, I'd be really interested in getting some hints if anybody knows how a "typical" loop selection algorithm works. Couldn't find anything in the great wide web. Maybe I used the wrong keywords?

Cheers "ko'gen".

Mathieson
05-02-2009, 07:12 PM
I made a script a few months ago that does exactly this. It is still a wip, but is working well at the moment. I just want to add in extra functionality like exponential falloffs and maybe figure out a better method of calculating the weighting percentages.

I am currently defining a maximum sampling radius, cycling through all verts in the mesh and for each vert am collecting any bones whose center position falls within the max sampling distance from the vert as well as their distance from the vert. From there I use the distance values to determine percentages for each bone.

The problem I've been running into with this method is that obviously the sampling distance will change throughout the mesh, so certain areas hold up extremely well while others are really messy. I am thinking of trying another approach where maybe the sampling distance is determined dynamically by getting the distance of the closest bone to the vert and then sampling within another 50% of that distance for other bones. Might give better results.

Anyways, I'd like to hear others' ideas on this too.

EDIT: Should also add that I added functionality for it to only calculate selected verts and to take into account vertex normals to help go back and rework those areas that had problems on the first pass. It is still a bit of a pain going back and reworking those areas though.

kogen
05-03-2009, 10:14 AM
Hei Mathieson

thanks for your reply. Seems like we have the same thoughts of how a script like this should work. I've figured out this method when I started scripting, but kicked it, because of the issues you've pointed out. I guess there are minor problems with bones in areas like legs or arms. But I guess it get's really horrible if it comes to automatically weight shoulder areas or even the belly, right?

The method I'm using right now needs a closed point loop to start. The script expands this selection in the direction in which the bone is pointing, deletes the old selection and weights the new loop according to the average position of the currently selected vertices according to the length of the bone.

The problem with this method is: The algorithm stops if the average position of the currently selected vertices is out of the range of the currently used bone. So it can happen that there are vertices missing or not weighted well. It's okay for linear meshes with very clean edgeloops but it becomes a mess with more defined edgeloops.

Implementing an algorithm that pays attention to the topology of the underlying mesh structure may solves a bunch of problems (e.g. topology masking in ZBrush). But I'm really having no idea of how to start something like that. :(

Any ideas?

PEN
05-03-2009, 01:17 PM
I wrote something like this years ago, I think it was Max 5 maybe. I never completed it as I found that I was doing just as much work cleaning up the mistakes as it was to just size envelopes and then weight. Maybe some one has some better ideas on it then I do but it always worked great in simple examples and then fell apart in real world ones.

Mathieson
05-03-2009, 07:52 PM
I've been finding the same thing Paul. I have been getting better results on high-res meshes though, I guess because there is more information for it to work with. Either way, still lots of cleanup to be done. Not sure I am going to spend much more time on the script, its going to have to give better results to really be worthwhile.

Mirko, I added a "use normals" toggle to try to take care of some of these trouble areas. If the vertex's normal points away from the bone, that bone will be calculated, otherwise it will be ignored. This helped a bit, but it created some other problems as well (think clothing, for example, where there can be lots of extreme folds). It might be good to make give an angle threshold option rather than always a 180 degree check.

I started playing around yesterday with that percentage of distance idea I mentioned. I was getting some unexpected results, so I think something in my code must be messed up. I'll have to take another look at whats going on. I'm not even sure at this point that it will give much better results once I get it working. Worth a try though.

eek
05-03-2009, 10:28 PM
I've done this with LODs, but not the whole character - how do you define the characters volume? Also id be wary that this is just another form of the already existing skinWrap? or just a adding a standard skin mod?

I saw a paper recently that just marked edge loops of joints and did a volume skin on it. It was pretty nice but didnt handle any sort of elements, armor, skirts etc etc.

kogen
05-04-2009, 07:47 AM
Hei,

so obviously everyone started scripting something like this, but never finished it :D

eek: You're extremly right. To me this makes thinking about this script a lot more difficult cause whenever you think: "Hei, might be a good idea." There comes a thought to my mind like: "But, wait, isn't it similar to the existing envelope-weighting or Skin Morph Modifier? Argh..."
The problem is, that both methods are not very accurate, that's why I thought something like in ZBrush might be a cool idea to work with. Is there any chance you find this paper again, that you were talking about?

Mathieson: I had the same problems with the vertex angles. When I calculated the angle everything was right. But when I tried to work with this angle and create a dependency from it gave me always very strange results. I couldn't explain why.

PEN: As I said, there might be a script like this. ;) But is there no automatic way of doing things like that in the industry? I can't imagine this is still done manually, whereas automatization has flooded every other part of the business?!

What about checking the edgeloops per bone and creating as many cross sections as edgeloops with the average size of that specific edgeloop?

Guibou
05-05-2009, 01:50 PM
Hey guys, I was reading this post and found it really interesting.

I'm curious to know if anybody ever wrote a script that would normalize a character's skin according to a given value.

Let's say I've skinned my character using the paint weight tool, but in the engine i know the skin will be optimized with weight steps of 0.1
If i want to see the same result in Max, i would have to go through the skin and make sure i'm following that same rule, that way when i animate, i can see the exact same deformation of my character than it would be in the game.

I'm not looking for an actual script here, but i was wondering if anybody ever did that and if so what angle did you start from?

Thanks

PEN
05-05-2009, 02:38 PM
There might be solutions for auto Skin weighting out there but It doesnt mean that it works really well. Also in Max we have envelopes and they can be setup very quickly to get you started. In Maya you have to do some sort of auto weight setup to get close to what you can do with envelopes in a very short amount of time. This isn't saying there is a good solution out there, I just have not found it as of yet and over the years I have given it much thought.

kogen
05-05-2009, 03:26 PM
Hey Guibou,

interesting idea.
I guess this shouldn't be too hard to achieve.
All you'd have to do is checking your skinned vertices and determine if they are closer to an upper value or a lower value (like 0.13 is closer to 0.1).
After that you'd set the old value to the new value and that's it. For animating purpose I'd store the old values of all vertices in an external file so they can be easily replaced.

Well actually I'm a bit interested in trying this. Let me know if you need any help :)

Cheers "ko'gen".

IkerCLoN
05-05-2009, 03:43 PM
As I mentioned some days ago, using a sliced mesh as deformers using Skin Wrap gives you nice results, and it can be considered an automatic way to weight vertices after you convert that modifier to Skin. But it would be nice to see other ways around to automate things ;-) I'm using this for the last 4 characters I worked on and it's a pretty nice start for skinning, although if I have time I prefer to work with vertices from scratch (I rarely use envelopes).

One thing I think it'd be very useful is a 'lock weights' tool, so you can transfer weights from one bone to another without reseting them :D

eek
05-05-2009, 06:15 PM
Hei,

so obviously everyone started scripting something like this, but never finished it :D

eek: You're extremly right. To me this makes thinking about this script a lot more difficult cause whenever you think: "Hei, might be a good idea." There comes a thought to my mind like: "But, wait, isn't it similar to the existing envelope-weighting or Skin Morph Modifier? Argh..."
The problem is, that both methods are not very accurate, that's why I thought something like in ZBrush might be a cool idea to work with. Is there any chance you find this paper again, that you were talking about?


Here you go:

http://www-evasion.imag.fr/Publications/2008/LHGT08/RR-6406.pdf

Basically Atlas skinning. Not musch support for attachments etc..

kogen
05-05-2009, 06:34 PM
Amazing, eek, thanks a lot!
I'll print it out and make it my bedtime reading for tonight. :)

kogen
05-06-2009, 03:59 PM
Woha,

great article, I think I'll give it definitely a try. So here is my first general MXS question:
Is there any chance you can access the color of an edge?
I mean: Is there something like a way to highlight edges in a distinct color like the "Create Pelt-Seam"-Command does?

Or viceversa: Does anyone know how the edges are normally highlighted, when you select them for example?

Cheers "ko'gen".

Chinwagon
05-07-2009, 01:36 AM
What you want is bone heat for max.

Bone heat in Blender is a skinning methods that gives really good results by default. I'll let the blender people provide you with all the info.

http://www.blender.org/development/release-logs/blender-246/skinning/

:)

hotknife
05-11-2009, 04:11 PM
This is a little off-topic but http://www.cgcharacter.com/cgskin.htmldid an alternative to skinning. it worked in a similiar fashion to skinwrap but was much more flexible and gave what I thought was a great way of working.Shame it was discontinued.....especially as I bought it. oh well.

CGTalk Moderation
05-11-2009, 04:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.