New weight painting

Works in progress and technical screen shots.

Moderator: joepal

New weight painting

Postby blindsaypatten » Wed Oct 24, 2018 2:28 am

I decided to look at weight painting again. I've looked at improved weight paintings before, but never ended up reusing them. So I have written a little Blender plugin that saves the weight painting of the active object to a json format text file. Given that you can already transfer a weight painting between two objects in Blender this is no big deal, but I plan to build it into my mhx2 exporter/importer so that I can automatically replace the default painting with my favorite painting.

I repainted the left shoulder of a toon and created a video showing the default painting on the left and the new painting on the right as the shoulder is abducted:
https://www.youtube.com/watch?v=CJ3RZJnTYs0

I used the corrective smooth modifier for both shoulders. While far from perfect the new painting looks better in pretty much any position. While I don't think you can achieve perfection just with weight painting I expect that someone with more experience can do better so if anyone has done a good weight painting it would be great if you could share it. It would certainly speed up my project!

If I can put together a good weight painting I'll make a stab at figuring out how to get MakeHuman to use it.
Attachments
shoulder.zip
Weight painting with improved left shoulder
(228.25 KiB) Downloaded 606 times
jsonweights.zip
Blender addon to export/import weight paintings to json files
(8.48 KiB) Downloaded 623 times
blindsaypatten
 
Posts: 586
Joined: Tue Mar 14, 2017 11:16 pm

Re: New weight painting

Postby joepal » Wed Oct 24, 2018 7:46 am

If you download default_weights.mhw from here: https://github.com/makehumancommunity/m ... /data/rigs (it's too big to display inline via github), you can see that it is a very simple json file.

The format is

Code: Select all
{
    weights: [
        (bone name) : [
            [ vertex number, assigned weight ],
            [ vertex number, assigned weight ],
            ...


The idea is that the human mesh gets vertex groups with the same names as the bone names, and that the weights are the vertex's weight in that vertex group.

So to get MH to use new weight painting, essentially change the appropriate pairs of vertex number and weight in the vertex group in this file.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: New weight painting

Postby blindsaypatten » Wed Oct 24, 2018 4:29 pm

Ah! Fantastic!

So, I have attached a Blender addon that will add an option "Export MakeHuman Weights" to the File/Export menu. The file is in the same format as the default_weights.mhw file on github.

Note that the format is slightly different from the one in your post, it is:
Code: Select all
{
    "weights" : {
        "toe4-2.R" : [
            [5987,0.0236],

i.e. weights is a struct rather than an array

Well, I gave it a try, and it was close but no cigar. The mesh has some distortions near my modified painting, and when I export the toon back to blender the painting is not quite the same.

When I went to replace the default_weights file I saw that I had done work with that file previously, and now that I think of it I remember that there was more to it. Painting helpers or something. I'll go look for the thread.
Attachments
mhjsonweights.zip
This is obsolete, use the one from the next post which also does importing
(9.23 KiB) Downloaded 586 times
Last edited by blindsaypatten on Wed Oct 24, 2018 7:55 pm, edited 1 time in total.
blindsaypatten
 
Posts: 586
Joined: Tue Mar 14, 2017 11:16 pm

Re: New weight painting

Postby blindsaypatten » Wed Oct 24, 2018 7:28 pm

From a previous thread:
Aranuvir wrote:The best approach for weight painting is:

  1. Install all makehuman-utils
  2. Load a base mesh with helpers via MakeClothes or MakeTarget
  3. Import the default skeleton via Import/MakeHuman rigging
  4. Do your weight painting, don't forget to paint the helpers, too
  5. export via Export/MakeHuman rigging to an different location
This should create a new weight map, usable in MH, when renamed correctly

Attention: the exported skeleton will NOT(!) be usable, unless it was fixed by hand: viewtopic.php?f=3&t=13256&p=33801#p33801


The makehuman-utils refers to this Blender addon:
https://bitbucket.org/MakeHuman/makehuman-utils

One key here is you need a mesh with all the helper geometry, and that you probably want to paint the appropriate parts of the helpers too.

So I did a test run:
Load an average male human with helpers via MakeTarget
Export a toon with gender 100% male and race 100% caucasion (this is what Average Male is) and the default skeleton
Parent the MakeTarget produced mesh to the armature from the toon with automatic weights (helpers did not get weighted...)
Delete all the vertex groups
Use my addon to load the default_weights from the makehuman/data/rigs directory onto the mesh

That gives me a mesh with the helpers painted. In theory I could now start painting but I don't know how to get to the body mesh when it is covered by the helpers (it's all combined in a single mesh). I can hide them in Edit mode but they come back when I leave Edit mode.

Maybe I should write a script that copies weights from a body mesh to the mesh with helpers after deleting all the body mesh vertices from the vertex groups on the mesh with helpers... Actually, maybe just combine a painting of the body mesh with the values for the helper meshes from the default painting. But, then the tights helper, for example, wouldn't benefit from the new painting.

I'm sure there's a better way, I usually find that better way immediately after finishing writing a script to do it...

I'm not sure if step 3, loading the armature, is supposed to be done with some util I haven't found yet, and if that would make a difference.
Attachments
mhjsonweights (5).zip
New addon that does imports as well as exports
(9.28 KiB) Downloaded 600 times
blindsaypatten
 
Posts: 586
Joined: Tue Mar 14, 2017 11:16 pm

Re: New weight painting

Postby joepal » Wed Oct 24, 2018 8:52 pm

blindsaypatten wrote:That gives me a mesh with the helpers painted. In theory I could now start painting but I don't know how to get to the body mesh when it is covered by the helpers (it's all combined in a single mesh). I can hide them in Edit mode but they come back when I leave Edit mode.


I'd use a mask modifier. Create a vertex group for the body as such, assign all body vertices to that group, and refer to that group when you add the mask modifier. Set the mask modifier to be active both in rendering and in viewport. When wanting to see the helpers and not the body, simply flip the direction of the modifier.

mask.png


In this image, the toon body has all the helpers, but they're not visible due to the modifier.

As a side note, the image is taken from when using the latest version of my new importer. It automatically creates this mask modifier as a part of the import process.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: New weight painting

Postby blindsaypatten » Thu Oct 25, 2018 10:53 pm

joepal wrote:I'd use a mask modifier. Create a vertex group for the body as such, assign all body vertices to that group, and refer to that group when you add the mask modifier. Set the mask modifier to be active both in rendering and in viewport. When wanting to see the helpers and not the body, simply flip the direction of the modifier.


Perfect! Thanks!

I finished my first draft of a new weight painting, and the results look pretty good in Blender:
painting_shoulder.png

painting_shoulder_elbow.png

painting_knee.png


And I was able to merge it with the default_weights.mhm file so that my body weights replaced the body weights in the defaults but the rest of the weights were unchanged. Unfortunately, it doesn't look nearly as good, not really significantly better than the default, and some glitches. Exporting back to blender it is at least partially restored.

Part of the problem is the lack of the equivalent of the Corrective Smooth modifier in Blender. But I don't think that alone explains it. Perhaps it will be better to just keep the repainting in Blender, inserting it during the export/import process.
blindsaypatten
 
Posts: 586
Joined: Tue Mar 14, 2017 11:16 pm

Re: New weight painting

Postby FreezyChanMMD » Wed Nov 07, 2018 3:39 pm

Looks terrible and does not work
stop being a liberal snowflake
User avatar
FreezyChanMMD
 
Posts: 6
Joined: Wed Nov 07, 2018 3:36 pm


Return to WIP (Work In Progress)

Who is online

Users browsing this forum: No registered users and 1 guest