Weighting a MakeHuman Mesh

A place for unofficial tutorials posted by MH users

Moderator: joepal

Weighting a MakeHuman Mesh

Postby punkduck » Thu May 02, 2019 7:41 pm

The last weekends Elvaerwyn and I used for some work on new proxies.

Elv created new proxies with more loopcuts in "flexible" regions like knees, elbows or the lowerarm/wrist area. Since a proxy is not different from a piece of cloth, we have the same problem, bones may influence parts more than they should do.

In MakeHuman a new weighting instead of the weight-copy is one of the possibilities. I am pretty sure, most people don't know that each piece of cloth could have an own weight-map based on the default skeleton. Check the standard shoes.

If the parameter

Code: Select all
vertexboneweights_file <weightsfilename.mhw>


is set in the .proxy or .mhclo file, then the weights are not copied, instead the weights from this file will be used. The weights file is in JSON format, so it is also human readable. It contains an array of pairs of vertex-number and assigned weight for each bone.

I will now explain how you can do your own, so with some skill everybody else can do it for clothes or proxies.

Especially for proxies a fully symmetric mesh will make weighting easier. If it is not symmetric we have to weight both sides individual. This results in unpredictable behavior.

Let's assume this had been done. To test it, there is a script create_mirror_tab on github.

https://github.com/black-punkduck/MakeHuman-Helpers/blob/master/create_mirror_tab.py

If the mirror table contains unmatched lines (lines with vertex number -1), then it is not possible. Here is my real life example ...

Code: Select all
./create_mirror_tab.py -b /data/punkduck/makehuman/v1/data/proxymeshes/elvs_maleproxy1.obj >/tmp/mirror_table.txt
16238 vertices processed
0 unmirrored vertices


If it is not a 100% symmetric try with -m 0.003. If that does not help and there are still differences the mesh is not symmetric. You can try the script on the base.obj.

So weighting is not very easy. Therefore it is best we start with the weights assigned by MakeHuman itself. Use your new proxy on a default female or male mesh, that is only the gender slider moved completely to left or right. Then add the default skeleton with toes and export with mhx2. The character is ready to weight and the vertex order is still the same.

In Blender import without modifications. Now change the weights.

Lets take an example. When I first explained MakeHuman to someone, of course I had a female with the default proxy and she sat nude and relaxed on chair. Unfortunately my texture is .. ehm ... well ... rather natural. :oops: The rest of the explanation I had to do the next day. A gynecologist would have been happy ... I guess. :shock:

To avoid this (btw also for male characters) I had to change weights in the crotch region. The next picture will explain how I did that.

weighting_tutorial1.jpg


Step 1:
First I select the region where I wanted to lower the influence of the upperlegs. So I completely set upperleg02 to zero by removing it and upperleg01 to 0.05 by simply assigning this value. With the vertices selected, look for upperleg in the vertex groups box and press remove for upperleg02. For upperleg01 assign "Weight:" to 0.05

Step 2:
Now change to weight paint mode and select the button to make the selected vertices from edit mode also visible in weight-paint mode. Press "normalize all" and do not lock active group (example is without upperleg assigned to 0.05) Normalizing means to change weight so that the sum of the weights equals to one.

Step 3:
Now increase the selection (CTRL NUM +).

Step 4:
And press smooth a few times with all groups.
Now the influences of the upperlegs are reduced, most weight is bound to spine05 and it looks better ...

Similar we can change weights for the knees. We just have to change the influence of the upperleg and lowerleg, The next image is an example of before and after the change. I only did the change on left side.

weighting_tutorial2.jpg


So we have created all the weights. Since I did not found an MHW exporter I wrote my own. You can download it from github.

https://github.com/black-punkduck/MakeHuman-Helpers/blob/master/mhw_export.py

I only tested it for 2.79 so far.

Put the file in the plugins directory of Blender and activate it (category is MakeHuman, so same as MakeClothes etc.). Select your weighted character in Object mode and export the weights with Export MHW. There is a small box, where you can add additional parameters.

export_weights.png
export_weights.png (19.36 KiB) Viewed 13054 times


All values smaller than the precision (3 = 3 digits after comma) will be ignored and the JSON file is created with the values grouped in four columns (a kind of beautification for readability).

In case you use a symmetric mesh and tested symmetry before you can use the generated mirror-table. At the moment this is not implemented in Blender. The script must be executed on shell/cli, the name of the generated mirror-table must be put in a configuration file. The script already creates a symmetric weights table. The command will be changed so it also creates the header in case of "=all=" in the next days. At the moment you have to add them manually. The script is also on Github in the same directory.

Code: Select all
symmetrize.py -f weightfile "=all="  >/tmp/mirrored_weights


Without the ORIENTATION parameter left side is copied to the right side.

Unfortunately I only could test this on Ubuntu Linux. MacOS will work identical, as far as the python interpreter is found. I guess in windows the python interpreter must be written in front of the command. Maybe someone tries that and gives response (e.g. create_mirror_tab.py on original base mesh). All commands create the output into standard output, nothing will be overwritten by accident.
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany

Re: Weighting a MakeHuman Mesh

Postby MTKnife » Fri May 03, 2019 4:46 am

I can't get either proxy to load--can anyone tell me where the app stores its error logs?
MTKnife
 
Posts: 311
Joined: Tue Sep 01, 2015 5:22 am

Re: Weighting a MakeHuman Mesh

Postby bogdan666 » Fri May 03, 2019 6:32 pm

With Version 1.1.1 the proxies fail to load for some reason, but if you use MH Alpha 3, it loads correctly.
bogdan666
 
Posts: 77
Joined: Wed Aug 08, 2018 6:16 pm

Re: Weighting a MakeHuman Mesh

Postby punkduck » Fri May 03, 2019 7:03 pm

MTKnife wrote:I can't get either proxy to load--can anyone tell me where the app stores its error logs?


I guess you speak about MakeHuman ... because I did a tutorial about at least 4-5 different tools. ;)

Well, when MakeHuman does not load one of those proxies, you will find the reason in the Tab Utilities / Logs, where the current log is presented.
This log is identical with the file in your users documents folder starting normally with makehuman/v1 and is called makehuman.log.

In a way this should not be different on Mac, Linux or Windows.

Check if the .mhw files from the zip-files are installed in the right folder. In my case they are in the same directory as the proxy and obj file. I asked Joel to add an .mhw slot to proxies in the assets to make the need of the .mhw visible.
This might take a few days, since we are not working 7x24 in MakeHuman :mrgreen: .

The proxies I used on an old official 1.1.1 version. As far as I know, MakeHuman code did not change for the proxies, but maybe the pathes are different.

Best help in the moment: look into the error log, there you can see which path MakeHuman expects. MakeHuman was always able to handle own weights, because the official shoes have own weight files as well.
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany

Re: Weighting a MakeHuman Mesh

Postby MTKnife » Fri May 03, 2019 11:30 pm

punkduck wrote:
MTKnife wrote:I can't get either proxy to load--can anyone tell me where the app stores its error logs?


I guess you speak about MakeHuman ... because I did a tutorial about at least 4-5 different tools. ;)


I said "proxies", and you guys just uploaded two proxies, so I thought it would be obvious, and at the very least, even were it not, I don't think it merited what appears, from my admittedly flawed perspective, to be a borderline snarky comment. (And I admit that perspective is colored by the discussion about the dress asset, though that's probably not your own fault.) While I would certainly benefit from using the proxies, I am trying to help you out here, rather than waiting until someone else posts about a problem.

Well, when MakeHuman does not load one of those proxies, you will find the reason in the Tab Utilities / Logs, where the current log is presented.
This log is identical with the file in your users documents folder starting normally with makehuman/v1 and is called makehuman.log.

In a way this should not be different on Mac, Linux or Windows.


Ah, didn't realize I could view logs within the GUI--that's useful. Can't believe I missed that.

Check if the .mhw files from the zip-files are installed in the right folder. In my case they are in the same directory as the proxy and obj file. I asked Joel to add an .mhw slot to proxies in the assets to make the need of the .mhw visible.
This might take a few days, since we are not working 7x24 in MakeHuman :mrgreen: .

The proxies I used on an old official 1.1.1 version. As far as I know, MakeHuman code did not change for the proxies, but maybe the pathes are different.

Best help in the moment: look into the error log, there you can see which path MakeHuman expects. MakeHuman was always able to handle own weights, because the official shoes have own weight files as well.


I think the problem is the MHW files--although I skimmed your post above, I didn't read it in enough detail to realize I needed to download the MHW files in addition to the proxies. None of the three asset files mentions the need for the MHW files to be placed into the same directory as the PROXY and OBJ files (and the weights assets--the zip file--mentions Blender node setups, which made me think it wasn't for direct use in Makehuman).

Elv might want to expand the asset descriptions, esp. for people who first encounter the new proxies through the community assets plug-in, rather than by reading this thread.
MTKnife
 
Posts: 311
Joined: Tue Sep 01, 2015 5:22 am

Re: Weighting a MakeHuman Mesh

Postby MTKnife » Sat May 04, 2019 4:00 am

OK, I can definitely see the improvement, so good job.

I do however see some skin showing through skin-tight clothing (right around the tops of stockings on the model I'm looking at right now). It looks like what happens when a proxy is based on the default adult female rather than the Caucasian adult female.
MTKnife
 
Posts: 311
Joined: Tue Sep 01, 2015 5:22 am

Re: Weighting a MakeHuman Mesh

Postby joepal » Sat May 04, 2019 9:14 am

I have now added a weight field to the proxies node type, so that mhw files can be uploaded.

However, this will also need changes in the asset db export on the server, as well as updated asset downloader plugins locally (I think, might not be necessary) for everyone who wants to get the weights files.

But when/if elv and duckie update their assets with weights files, it should at least be possible to get the files manually.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Weighting a MakeHuman Mesh

Postby bogdan666 » Sat Aug 10, 2019 8:56 am

I've made a custom weight mod and exported the .mhw from blender, but how to generate the other files (.obj,,.proxy etc.) if I want to use the new weights with the default skeleton and with the adult female genitalia healed proxy in MakeHuman?
Just renaming some files didn't help for MakeHuman to register it correctly, although it did show up in MakeHuman.
bogdan666
 
Posts: 77
Joined: Wed Aug 08, 2018 6:16 pm

Re: Weighting a MakeHuman Mesh

Postby punkduck » Wed Aug 28, 2019 7:09 pm

bogdan666 wrote:I've made a custom weight mod and exported the .mhw from blender, but how to generate the other files (.obj,,.proxy etc.) if I want to use the new weights with the default skeleton and with the adult female genitalia healed proxy in MakeHuman?
Just renaming some files didn't help for MakeHuman to register it correctly, although it did show up in MakeHuman.


Sorry for not answering in between, but doing that with a smartphone from my vacation was not really an option (and I have no examples on this thingy to check if I write rubbish) :mrgreen:

For me all files are here:

<HOME>/makehuman/v1/data/proxymeshes

If you really re-weighted the female genitalia, then you have only to add the weight-file name to the .proxy file. The .proxy is identical to a .mhclo. It also refers to an .obj-File. By adding your filename to the .proxy, MakeHuman knows that it has to recompile and creates a new .mhpxy and .npz-file.

Please make sure makehuman has the permission to do that. Typical it works when the proxy is in your own directory, e.g. on Linux it will not work, when the file is in a system directory (I guess all other OS work similar). When the .mhpxy and .npz files were not overwritten, you work with the original version. You can check this by simply looking at the file date.
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany

Re: Weighting a MakeHuman Mesh

Postby bogdan666 » Sat Aug 31, 2019 12:49 pm

I've imported a MH Character into blender as proxy only (default rig, adult female genitalia healed, set to fully caucasian / fully female).

Then I've imported my character body mesh (of the same topology type with identical vertex count) with custom weights (into blender).

Next I did a weight transfer from my char body mesh with custom / corrected weights to the "proxy" char.

After this I removed my custom-weighted char body mesh.

What to do next? I am not able to export my proxy mesh, only as weights file.

MakeClothes has no option for exporting my proxy.

Should I export it only as .mhw and than make a copy of "adult_female_genitalia_healed.proxy", rename it and change the file names inside of it?

Do I have to write the name of the .mhw file into the .proxy file manually and how to name it.

.proxy has "name" before it and .obj has obj_file put before it but how to call a weight file from .proxy?

Am I on the right path?
bogdan666
 
Posts: 77
Joined: Wed Aug 08, 2018 6:16 pm

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest