Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Morphs creation (Copy/Move/Delete/Rename/Backup morphs tool done) #226

Open
TetoTheSquirrelFox opened this issue Jan 12, 2020 · 58 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@TetoTheSquirrelFox
Copy link
Contributor

TetoTheSquirrelFox commented Jan 12, 2020

So, I try to help by making tools to create like morphs (or muscle if I can figure how it works).

But I had to answer few questions first :

  • What is the scope ?
  • When can the user create morphs ?
  • Where are tools on the panel, are they available all the time ?
  • When can we lunch ?

So what I think about that:

  • To be able to create good morphs that can be used everywhere, user must starts with the basic shape of one of the 4 big types available in MB-Lab : male, female, anime male, anime female. So, to start with something, I created a “Base female f_NO01” (file characters_config.json) that has no phenotype, no race, and is the base model that used Manuel.
  • I also gave to this model a basic albedo.png that looks like clay. Not very good, but well...
  • Then I gave it no morphs, no phenotype, nothing. So it’s the most basic model we can have.
  • I also created dedicated directory for this type (\data\presets\none_female_base) with no file.
  • For me it’s the model user must use to make his own morphs for all female models (realistic female here)

You can see the content in characters_config here:
"f_no01": {
"description": "Generate a base female character for creating morphs",
"template_model": "MBLab_human_female",
"name": "f_no01",
"label": "Base female (F_NO01) (AGPL3)",
...
"texture_sclera_mask" : "sclera_mask.png",
"morphs_extra_file": "",
"shared_morphs_file": "",
"shared_morphs_extra_file": "",
"bounding_boxes_file": "human_female_bbox.json",
...
"vertexgroup_base_file": "human_female_vgroups_base.json",
"vertexgroup_muscle_file": "human_female_vgroups_muscles.json"
}

Problem is that some morphs could be very specific to a race or a phenotype, and could not work properly in all models for a reason. So I decided that user could use the model he wants, and create his own morphs while other morphs are already used. To assure that, I put the “morphs editor” in the Pre-Finalized State session (gui_status == "ACTIVE_SESSION") and put it between “random generator” and “measures”. So, for the user who chooses “F_NO01” he can create, and for the others he can use other morphs as well.

So, as MB_Lab is not designed to create bodies from scratch, but more to use what it is available, I tried to be as simple as possible, while let the user to have the most useful tool to create new morphs.

So now here are the problems I’m facing :

  • Let’s take the model f_ca01 in characters_config.json. Few lines are dedicated to the morphs.
    "name": "f_ca01",
    "morphs_extra_file": "",
    "shared_morphs_file": "human_female_morphs.json",
    "shared_morphs_extra_file": "human_female_morphs_extra.json",
  • shared_morphs_file & shared_morphs_extra_file are basic morphs shared by all phenotype from female Caucasian. (extra_files is for fantasy, basically). Here it’s simple, all females share the same files. But it could be something else.
  • f_ca01 allows to use morphs that are dedicated to the type (female Caucasian) and the files need to be in the proper format for its name: “f_ca01_whatever_optionalWhatever.json”
  • More important: under those files, a same morph is split in two, for minimum values and maximum. Each morph end with _min or _max, so the engine can construct the final morph, from 0 to 1 (0,5 is the model before morphing).
  • morphs_extra_file: I think that the intent was to allow user morphs shared buy a whole type?
  • So under the directory \data\morphs you have 2 types of files, the ones who are dedicated to a whole range of human (male, female, anime male, anime female) and the others dedicated to types, and it seems that we can add all files we want if they are properly named.

At first, the tool would have looked like this (on the panel):

  • Create base model → copy all vertex from actual model shown, whatever it is.
  • Load base model → Load an old model.
  • Load work-in-progress → Load a model for a morph in progress.
  • Reset models → reload work-in-progress model.
  • Morph type → a list where we can choose if the morph will be for one type in particular or for a whole range.
  • Body type → Male or female.
  • Type name → (for example) an02
  • Type name extra → none or a name like the pseudo of the author.
  • Morph name → A name for the morph.
  • Min or Max → the target morph is for min values or max.
  • Save work-in-progress → Save all actual model as a work-in-progress.
  • Quick save → No dialog, take the name, add _min or _max, and _000 (or _001, _002, …) and save the morph, aka the vertices that are their location changed.
  • Save final morph: Same thing, but we have to choose min and max files, and the file is properly saved in the dedicated directory.

But, first I wanted to have my own models, copies of the ones used by the engine, but after a while I started to think that it was not good. The engine is complex, and I should keep a coherence with it. The model the user is working on is linked to the engine, so let’s keep it that way. And the engine has already many useful tools like reset, loading, saving…
So, if the user wants making morphs from base model, no problem, he can use the “reset character” button. If he wants to create while character already has morphs applied, he can use ‘import/export character”.

So now the tool looks like this :

  • Morph type → a list where we can choose if the morph will be for one type in particular or for a whole range.
  • Body type → Male or female.
  • Type name → (for example) an02
  • Type name extra → none or a name like the pseudo of the author.
  • Morph name → A name for the morph.
  • Min or Max → the target morph is for min values or max.
  • Load work-in-progress → Load a model for a morph in progress.
  • Save work in progress→ No dialog, take the name, add _min or _max, and _000 (or _001, _002, …) and save the morph, aka the vertices that are their location changed.
  • Save final morph: Same thing, but we have to choose min and max files, and the file is properly saved in the dedicated directory.

The workflow would look like this :

  • I choose for what type the morph is for. → Type name = as01
  • Morphs are already existing for the model, so I write my pseudo for save files → Type name extra = Teto
  • Morph is for this model → Morph type = dedicated
  • For female → Body type = female
  • I’m sculpting for min values → Min or Max = min.
  • I do my stuff → Save work-in-progress 4 or 5 times.
  • It’s done, same thing for Max values.
  • It’s done. Save the morph. The file name is automatic, I just have to choose the proper file for min and max values. The file is saved in the dedicated directory. If the file already exists, the morph is added in the file. If the name of the morph already exists, the new one replaces the old one.

I’m working on it now, and if you agree, I’d like to make a morph.py dedicated for this, so the changes in other .py files would be minimal. I’d like to talk about the work in progress here too.

@animate1978
Copy link
Owner

Quite impressive! I will have to read this over again as I only read through it once but so far what I see I like.

Of course making a new morph Python script would be ideal.

We can make this a project for the next version perhaps?

@TetoTheSquirrelFox
Copy link
Contributor Author

Thanks. ^^

About a new project, why not, but I'd like to be sure that what I'm doing goes somewhere. For now I'll change the existing python files to "prepare" the creation tools, and will post the changes here.

@TetoTheSquirrelFox
Copy link
Contributor Author

image
Now, first thing to do is to store a copy of the body (all vertices to be more specific) because after sculpting the morph, I need to compare with a base, and as the actual body has changed, I need an untouched body to compare with.

But I can't write body_as_a_base = actual_body, I suppose, and I must something like body_as_a_base = actual_body.duplicate() and make a real copy, not an instance. I'll on this tomorrow. And I think that will help me for comparing 2 body objects.

By the way, about the classes I'm modifying : the changed code is always between
#Teto
and
#End Teto
So when it will be done, I will be able to send the files to you and it will be easy (I guess) to change the files in master. Please tell me if I'm wrong.

@Noizirom
Copy link
Contributor

Noizirom commented Jan 15, 2020 via email

@TetoTheSquirrelFox
Copy link
Contributor Author

No no, it's waaaaay simpler than that. ^^
Actually I want to make a copy of the vertices of the shown model. And a python program already exists for this (it writes in a file, I just want to make a special object that stores the vertices).
After that, user does his thing with Blender sculpt tools (without touching the number/name/id of vertices of course).
And at the end the tool checks just the differences between the base and the sculpted, then write them in a json file in order to be a regular morph.

So no, I don't "touch" anything in the model, I just check the differences between 2 states of a same model that is entirely handled by the engine (which is complex, like, really complex).

@Noizirom
Copy link
Contributor

Noizirom commented Jan 15, 2020 via email

@Noizirom
Copy link
Contributor

Noizirom commented Jan 15, 2020 via email

@TetoTheSquirrelFox
Copy link
Contributor Author

Nope, it's this file.

@TetoTheSquirrelFox
Copy link
Contributor Author

Quick update :
image
Now the UI is done. I think that if the thing is finished, I will have to change things here and there, but for now I need something working for users.

@TetoTheSquirrelFox
Copy link
Contributor Author

Great great news today ! ^^

I copied the great co_to_js.py int the class that is executed when user clicks on button "Store actual body vertices". I had to change things because python is handled differently when used in console and inside the plugin. So after changed every line because of this ^^, I did this :

  • I stored in a file the body shown on screen, after have created it.
  • on "Edit mode", I changed 1 vertex (somewhere on the arm) with mirror enabled, so the other arm changed accordingly.
  • Store the body again.
  • So now I have 2 .json files, that I open with Notepad++
  • I compare them (it's easy, Notepad++ has a module made for)
    And voilà ! Only 2 vertices changed in the file :
    image
    image
    The colors are ugly but that's not the point. On left, base body.

I was worried before the try, because I feared that the data stored by MB-Lab were not the data used by Blender. So if I changed something in the body (by using sculpt tools for example), the changes would not be "seen" in MB-Lab objects. I don't know if I'm clear. Anyway, it's not the case, that is good for me.

So, now I know that it works, animate1978, the thing can be a project now ?
Anyway, I have a lot of work to do.

  • First, be able to do the comparison in the engine, not very difficult I think, I know how to do this, I just have to collect the index of each changed vertex, and do a subtraction "new - old" and store the result in a json file.
  • This way, the tool would be barely usable for users.
  • And then I'd work to make the tool really useful, like allow to write many morphs in one file, manage directories for users morphs, and to the stuff written above.

Stay tuned !
Teto.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation Morphs creation (it's happening!) Jan 20, 2020
@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (it's happening!) Morphs creation (it's working!) Jan 28, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

It's working !
So what I did today : having a full comparison between 2 lists of vertices, with index, in order to be saved.
I took one character, stored its vertices. Disabled smoothing.
image
Went to Edit mode, changed 1 vertex (2, because symmetric edition)
image
Asked for the result and voilà !
image
Not sure yet, but I think that the indexes are good.
Now it's not over. What I have to do

  • Seems that when I reset the character, and try again, Blender doesn't like at all. But doing things, store, doing other things, store, and so on, then finalize the differences works well.
  • I have to save it in a file, with proper name. Manuel didn't reinvent the wheel, and uses strictly json library for that purpose, so it seems I just have to make a dictionary with keys (the name of the morph) and values (the changes) to write a file in the good format. I'm on it.

@TetoTheSquirrelFox
Copy link
Contributor Author

Now I'm almost there.
image
As you can see, the UI changed a lot, and many parts of the name or the morphs can't be changed because they are dependent of the model.

The only thing that I have to do is to put data in an opened json, add or replace morphs, and save it. For the moment, if a morph already exists, it is replaced. Everything else seems to work.

@animate1978 animate1978 added the enhancement New feature or request label Feb 4, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Feb 4, 2020

So V0.95 is done, is working (I hope) and was sent to Animate1978 for approval.

So what is it now ?
It's a tool that allows the user to make his own morphs, based on the model he chose .

  • The modifications can be made for the whole gender he's working on (human female, realistic anime male, ...) of for a particular type (male Asian, female Caucasian, and so on)
  • the tool is able to do autosaves, and file names have rules in order to be understood by engine when they are loaded. The tools provides mechanisms to avoid wrong naming.
  • The tool has unfortunately limitations.
  • The author is not fully fluent in english. Feel free to comment/correct the words used for the UI. ^^

The tool :
It changed a lot since I started to code. From something with many things to write before to be able to save the work, it's something now very straightforward, as the name (for the morph, for the file) must follow strict rules.
However, now the engine can load many files for morphs as you want. Before this tool it was just 5 : shared morphs (for a gender), shared morphs extra, and a third one (not used by the engine), plus 2 other files for morphs specific to body types. Now with the tool you can add any files you want, the ones you made and the ones made by others.

So, what have we get ?
Once the base character is made, you can choose the Morphs Creator tool and you have this:
image
Here is a rapid view of functions:

  1. Store base body vertices : The base model you're working on. Button to press before any change in vertices.
  2. Morph wording - Body parts -> Label for the content below.
  3. Body part :
    image
    Fun fact, it seem that we can have any body parts we want. But for the sake of sanity, I just used the standard.
  4. Name : Name of the morph. the tip shows the format. MyOwnMorph01 for example.
  5. min/max : If it's for min values of the morph, or max values. There are other values available (seen in some files) but I don't know what it's about. By the way, a morph can have just a min (or just a max), the engine doesn't mind and works well.
  6. Morph wording - File -> Label for the content below.
  7. Spectrum. whole gender or specific to a body type. Important : labels below show the name of the file, depending of your choice. And yes, you can save for both types (see below).
  8. Ethnic group : If empty, the one used by base model is used as name. If not, it overrides the base name.
    image
  9. Extra name : Basically the name of the author, but can be something else to separate morphs files.
  10. Autosave : If enabled, each time you save the file, a new file like m_zz99_morphs_pseudo_001.json
    (002, ... 999) is created with the morph. The count is reset for each session. And take care to move the files somewhere else after closing Blender to avoid overload.
  11. Quick-save work-in-progress. A little explanation here. You can change the shape of the model in edit mode or sculpt mode, but don't forget to disable 2 things :
    image
    DON'T change the index/name/number of vertices. NEVER. You just can change their location.
    When it's done, you can press the button. After that you can change things (or save with autosave), and press the button again, no problem.
  12. Finalize the morph. At last you save the morph :
  • If the file name is an existing file -> the file is opened, and if the morph already exists, it is replaced. So caution with standards files. Otherwise, the new morph is added.
  • If the file doesn't exist, it's created, and the morph added.
  • So, by changing gender, ethnic group or extra name, you can quickly add the same morph to many files.
  • For a morph with min and max, you have to do the work twice.
  • Important note : if the base model is not saved, or the changed model, nothing happens and a warning is shown. The morph is not saved either if the changes are too small. The engine doesn't count changes under 0.0001. So don't be alarmed if you sculpted a subtle detail but is not taken in account : it's just too small for the engine (and I didn't want to change that. Short story, the display of the number becomes scientific, like 1e-5 and Manuel didn't want to have this written in file, I guess).

Limitations :

  • There are no tools for files management. Well, not for the moment, because it's a lot of work for something not very useful (in my opinion). json files are human readable. When you know the structure, you can do many things manually. Maybe later. ^^
  • The model should be always selected. I saw weird things when I lost selection because I selected the lamp or something. Basically, use the tool with just one model displayed : the MB_lab body.

Typical workflow :

  • Create a base model.
  • Save it by "Store base body vertices" button.
  • Create a morph for min values. (and maybe save steps)
  • Press save work-in-progress button.
  • Save the file.
  • Reset the model.
    image
  • Create the morph for max values.
  • Press save work-in-progress button.
  • Save it in the same file.
  • Exit Blender
  • Open Blender, re-create the same model if morph was made for a specific body, of same gender otherwise.
  • Check Body measures, and the part where the morphs is stored.
  • Profit.

I wrote the main things to know I think. Don't hesitate to comment.
Teto.

Edit : And by the way, many many many thanks to the guy(s) who wrote the program "co_to_js.py". Without it, I think that none of this would have existed.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (it's working!) Morphs creation (V 0.95 done) Feb 5, 2020
@animate1978
Copy link
Owner

I just read the email, I have downloaded the sources and after work tonight I will go through and test this.

This is a pretty big deal, I was kind of waiting for this to come into being before I did any other work (aside from my own personal life being very busy atm)

I will also go through this issue and read through it so I can start developing some documentation.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (V 0.95 done) Morphs creation (V 0.96 done) Feb 5, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

OK, So I had an idea this morning and was able to make it this evening.
image
So you can see 3 tools under "finalize the morph" :

  1. The first save all vertices of the actual body shown on screen.
  2. You can load a model and use it as a base model (you don't see the result, there's no update, sorry).
  3. The same for sculpted body.

What is the interest?

  • If you have to leave but you are finished your new sculpt, you can save all data to build the morph.
  • I put a "proof of concept" here. Put this unzipped morph under your C:\Users\YourName\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\MB-Lab-dev\data\morphs. Create a female african (f_af01), under
    image
    Try the Morph "try".
    Enjoy.

Animate1978, I've just sent to you the modified files by mail.

f_af01_morphs_teto.zip

@animate1978
Copy link
Owner

I have added the code to my local copy, right now just checking it out, I still have to fully read through and test it but so far no outstanding bugs.

@animate1978
Copy link
Owner

It has been committed now

@animate1978
Copy link
Owner

logger.info("Looking for the retarget data in the folder %s...", simple_path(data_dir))

This is causing the tester on GitHub to fail.

Lint with flake8
5s
##[error]Process completed with exit code 1.
Run pip install flake8
  pip install flake8
  # stop the build if there are Python syntax errors or undefined names
  flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
  # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
  flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
  shell: /bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.6.10/x64
Collecting flake8
  Downloading flake8-3.7.9-py2.py3-none-any.whl (69 kB)
Collecting entrypoints<0.4.0,>=0.3.0
  Downloading entrypoints-0.3-py2.py3-none-any.whl (11 kB)
Collecting pycodestyle<2.6.0,>=2.5.0
  Downloading pycodestyle-2.5.0-py2.py3-none-any.whl (51 kB)
Collecting pyflakes<2.2.0,>=2.1.0
  Downloading pyflakes-2.1.1-py2.py3-none-any.whl (59 kB)
Collecting mccabe<0.7.0,>=0.6.0
  Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Installing collected packages: entrypoints, pycodestyle, pyflakes, mccabe, flake8
Successfully installed entrypoints-0.3 flake8-3.7.9 mccabe-0.6.1 pycodestyle-2.5.0 pyflakes-2.1.1
./morphcreator.py:225:70: F821 undefined name 'simple_path'
    logger.info("Looking for the retarget data in the folder %s...", simple_path(data_dir))
                                                                     ^
1     F821 undefined name 'simple_path'
1
##[error]Process completed with exit code 1.

I will look into it when I can

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Feb 6, 2020

OK, I did a copy/paste and forgot to erase simple_path.
So the line becomes :

logger.info("Looking for the retarget data in the folder %s...", data_dir)

And I remember : the method is not used , you can delete it. ^^

@animate1978
Copy link
Owner

OK. I am working on some documentation for this, we should also do some tutorials as well because I think this opens up a lot for people. This also opens up the door to a new model which I would like to start with this one as a prototype...

#161

I was successful to a point....

https://vimeo.com/359182294

I think if a workflow could be established, this model exported correctly (I think it was a weight paint issue) and then work on some morphs as a proof of concept before we go jumping in to making "production" models.

I have yet to fully test because I have not had time yet I plan on doing some this weekend.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Feb 7, 2020

OK. I've watched your video and it reminded me something.
So I may be wrong, but I don't think that weight painting is the source of the problem. Groups of vertices just don't move. And the step between full move / no move is too small, and too binary. The vertex move or not.
So what I'm guessing :

  1. It's a problem of vertices groups. It seems that muscles are attached to vertices by vertices groups. Your vertices could be attached to wrong group, like the fingers are attached to muscles for face ? But more I think about it, the more I think I'm wrong.
  2. But I think more about a problem of the deforming cage used to deform correctly the model when we deform it for poses. If a vertex or a group of vertices are outside this cage, they just don't move :

image
here an example shown with Blenrig.
Maybe I'm wrong, I don't know if MB-Lab uses a deform cage, but it really looks like it has this problem.

@TetoTheSquirrelFox
Copy link
Contributor Author

@animate1978 , I read you post on Patreon, I was sure that this tool should please you. ^^ You talked about your fight with phenotypes weeks ago somewhere.

So, the tool is ready, and should work. I did few tests, nothing wrong for me. Have fun with it.
Limitation : When your phenotype is done, you have to create a new Blender project (but without exiting it), and recreate the character.

Anyway, I almost made the 2nd related tool to Character Library, aka Presets. The save is not working for now (because... tired) but should not be difficult to do, as the principle is the same for Expressions and Phenotypes.

By the way, the files created have a nice indent now, I read the doc about json, and found the way to indent the data in file.

Now, how it looks like :
image

Side note : In fact, morphs are used many times to create all kind of bodies from a single model, before the user can use them again. I'll try to write something about it this week-end. Should be useful for general documentation.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Combined Morph Creation in progress) Morphs creation (Phenotype Creator done) Mar 12, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

So the second tool about Character Library is done. I didn't test it extensively, but it should work. Since previous post, I discovered that sometimes the materials are saved in the file for a reason. So I added the possibility to save (and work with) materials.
image
if material is not selected :
image
and if there's no name :
image

I delay the extensive test about Combined Morph Creator because of the way age/mass/tone are working. They use a special file, under /data/transformations where all morphs are changed by a linear interpolation, in order to change the age/mass/tone of a body. The file is different for most type of body, so it's interesting to also have a tool for that, as I think that it's very smart to have a body that can change by 3 cursors (age aka age, mass aka fat and tone aka muscle) without to have to change individually all morphs. And I think that understanding the principle will help me to understand how Combined Morph Tool should work.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Phenotype Creator done) Morphs creation (Preset Creator done) Mar 14, 2020
@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Preset Creator done) Morphs creation (Transformation Creator WIP) Mar 15, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 15, 2020

I'm done tonight.

So it's a new tool that is important because it allows the creator to change something important, the behavior of this :

image

So what's going on for now :
image
The preselection is done, and everything about saving file is done too, except the button for that.
We can also import a file to use it as a model.

How does it work ?
Basically age, mass and tone change directly all morphs (except expressions).
The trick here is that the cursor for age, for example has ONE value, from -1 to 1. However, this property is linked to other morphs (number can vary) that change body shape. As we just can't do result = age * body_part AND the min for age for this body_part can be different of the min of the morph itself, the engine must do a linear interpolation from -1/+1 of the age and 0/1 of the body_part. And that is done by "transformations" file.
Example :

  • A character goes from 18 years old (-1) to 80 years old (1)
  • Her size is almost finished at 18 (~0.45) and smaller at 80 (~0.35).
  • If you use body_size directly you see that you go from very small (0) to very tall (1).
    So the property in the transform file calculate with a linear interpolation the change of size, from a given size, during the life of the character.
  • So, each property of this special file has 3 values. The morph where it belongs, a value that corresponds to a min after interpolation, and the same for max value. This way the result can go from 0 to1 or from 0.1 to 0.2 if you want. So modifications in the morphs for age, mass or tone, can be really different, depending of the body part.
  • What is interesting here, is that we could imagine many different transformations files with different values, so for one body type we could have many different behavior due to age, mass and tone.
  • It's also a tricky tool, the creator must know what's he's doing, and as a given morph can be used for age, mass and tone at the same time, result can be weird very quickly.
  • Side note : by this technic we can exceed the limits of a morph (0->1). I've seen morphs that can go to 1.25 or more, and it's impossible to have this value directly.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 22, 2020

I'm done for tonight, but here is a quick wip review about the new tool for transformations, aka linear interpolation between Age, Mass and Tone, and the morphs, to quickly give fat, muscle or age to a character without having to use morphs one by one :
image
So you can see that morphs can be used many times.
I have a lot of work to do :

  • Make a link between preselection and selection. Preselection change directly the character, so cursors in the tool must have the same values.
  • Be able to load from a file, and of course
  • Be able to save in a file.
    This week, I'll try to finish the tool.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 23, 2020

OK. Good news and bad news (and something funny) :

  • Good news : It's almost finished. Tomorrow I try to allow saving files. We already can load files.
  • Bad news : Unfortunately, I tried many things but it's impossible to change the model in realtime. For example the cursor "Age" is on 1, I change something in hands (example), it's impossible to see directly the result on screen. You have to reset the character, and push the cursor on 1 again. It's understandable : transformation data are not used directly when you morph the character. It's when you play with cursors "Age" "Mass" and "Tone" that the data are checked and change model accordingly. I'll try something else tomorrow but I don't think that will work.
  • Funny news : There are errors in actual transformation files. Especially, some names are wrong ("legSize' instead of "legsSize" for example) so character is not totally well displayed. I'll try to correct the files after the tool done.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 24, 2020

Debug step. Was more difficult than expected, because during the day I was thinking about some little improvements, so... more time on them. Short story : I added the possibility to recover a state of the database. For example, while playing with cursors I am pleased with the result, I can say : please save this step. After that, if I play again but want to recover the previous step, I can. The step is not saved on disk, it's a kind of undo. Why that ? Because the tool doesn't work in real time. And saving on disk for each step would be very tedious very quick imho. So as a workaround, you can quick-save a step on memory, save it on disk (no counter this time, you change the name, it will be fast too), load saved files. The tool is not a tool that you use every day anyway.

I'm just annoyed that I can't show changes in real-time, to many things to change in the engine, I think that there are better works to do for now. The addon should be re-written from scratch anyway, in a creator point of view, not as an end user.

By the way, setattr has weird initialization sometimes, I wasted time because of that. For example if I do a setattr with a value of 0.45, sometimes the engine puts 0.499999999999122858 in memory.

But most of the time was used to link the change between the GUI (by user) and the data in engine.
Now, aside debugging and testing, I have to finish the save step/recover step thing, and allow to save in file, of course.

And since that is done, I fix the existing files, that have errors.

@animate1978
Copy link
Owner

animate1978 commented Mar 25, 2020

OK I have merged your code, fixed the conflict. @TetoTheSquirrelFox please make sure you pull before making commits, there was duplicate entries made during the conflict merge that I fixed. Nothing you did really it was just how the code merged during the conflict resolution.

@TetoTheSquirrelFox
Copy link
Contributor Author

Sorry I don't know how it works, what do you mean by pulling, reimport the project from your repository ?

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 25, 2020

@animate1978 I downloaded your repository, I guess it will work fine now.

I've just lost almost 2 weeks of work. I was struggling with the transformation tool, how link the content of UI with internal data base of the model, how to update in real time... (watch post above for more details).
The solution was so simple (I add the idea this morning). I just have to do the same kind of things that I did for morphcreator : using the prop to display morph and play with them to update the model in real time, then save the work step by step, here there will be 4 steps (see below):
image
So :

  • As usual, a button to reset the character.
  • Next, the usual stuff to change morphs one by one (Expressions are ommited)
  • Then you choose what the current shape of the model is for ("Save for" and "-1 to +1")
  • Then the name. If none; many buttons below are not available.
    The save/load buttons :
  • Save in file : Save the current combination in the file. So with a model with "Age" "Mass" and "Tone", plus 2 states (min, max), you have to push the button 6 times.
  • Clean save file. When all combinations are saved, the button clean the file from all unecessary morphs that are neutral (0,0).
  • Check compatibility You load a file, and it is compared to the data base of the current model. The result is stored in a txt file. What is checked is only morphs that are not in current model.
  • Export current model : Export the data base of the current model, for saving purposes for example.
  • Import for current model : Import a data base to the current model. May be interesting if you can choose between many data bases. It may be interesting to check the compatibility before.

The thing that hurts is the transfor.py file. It's almost empty now. ^^

@animate1978 The tool is not finished yet but I push it to see if you have problems to do the commit.

@animate1978
Copy link
Owner

Oh no, 2 weeks?? OMG I am so sorry, what happened? Was this because you pulled from this repository?

Good to see that this is coming together though, very impressive. I haven't merged the code yet but it should be ok to merge I will do that later on tonight or tomorrow.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 26, 2020

No, no, don't worry ! ^^ It's just that my 2 weeks on the job were useless because I found a better way to handle this tool. ^^ So have to rewrite it from scratch !

@TetoTheSquirrelFox
Copy link
Contributor Author

Quick update : My last tool related to morph is almost finished. Tomorrow morning I will be able to push the commit I think. In this tool about transformations (to change age, mass and tone directly) I wrote a small tool that checks the validity/compatibility of the file used by the model shown on screen. Mays be useful if, for a model, people add new morphs for example.

So the tool is also useful to see the errors in actual files used by Manuel, and I'm fixing them. But I won't do it for anime character. See below all errors the file has:
anime_female_base_transf.json.txt

Obviously the file is either:

  • Unfinished
  • Good files were not in the last release before Manuel gave up.
    It's a nightmare, too many morphs are missing.

@TetoTheSquirrelFox
Copy link
Contributor Author

Little post about few UI things I did. The tool about transformations (age/mass/tone thing) is over, and it's not that good, but I'll talk about that later. While finishing that tool, I also made few little changes in the UI (see below) :
During creation phase, I tried to have a more clear separation between "topics":
image
I think that doesn't touch the changes that @Anyeos suggests.
All about age/mass/tone is separated from the rest, and also the "after-creation tools".

And about MB-Dev, I changed the organization and icons to be more coherent with MB-Lab's UI.
image
I took icons from the other tab, and changed the order of the tools, to be more an the workflow that should have a creator.

  • First part : If we create content for a model, or if we create a new model from scratch.
  • Second part : all dedicated tools for edition/creation of the model. Here are shown the tools for edition. I separated the ones we can use before the finalization of a model, and after.
  • Third part : the content of the chosen tool.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 29, 2020

So, about my last tool, "Age, Mass & Tone" transformation.

I must say that I'm a little disappointed. But first, the changes since my last posts :
image

  1. In load/save parts you have 2 buttons (if file name is good) :
  • Load step. When pressed, the button loads (if file exists and is valid) the data for the category (age, mass, tone) and extreme (min or max) that the user has selected. Important : see the part "limitations" below.
  • Transformations are about age, mass and tone. And for each of them, you must have 2 values, min and maxi. So you have to do 6 steps if you want to create/modify a "transformation" file. This button allows you to save each step. The name must stay the same of course. When you save the last step, your file is complete and ready to be used. The file can even be used before, the engine doesn't crash.
  1. Tools.
  • Check compatibility : Loads a a transformation file you want, and checks if the morphs inside are compatible with current model on screen. The result is stored in a txt file with same name (+ .txt). It shows, for each category, the morphs that are not used by the engine, for a reason (bad name most of the time). Interesting if the user want to check if a file for another model can be used nevertheless.
  • Export current model : Export the data base of the current model (not the stuff done by the user) in a file. The icon is "freeze" because the name used is the name written in the text area, no dialog window to choose the name.
  • Import for current model : import a transformation file for the current model. When imported, user can play with cursors age, tone and mass to watch the results on the model.

Limitations : The tool works, no problem, but is also "What You See Is Not Completely What You Get" when you "Load step". Here the things to do to see what's going on :

  • Create a human character.
  • transformation file will be "human_female_base_transf" or "human_male_base_transf".
  • Put the cursor Mass to its maximum. Take a snapshot of the result.
  • In the text field "Name" under Tool wording-file, write "base".
    image
  • Click on "Load step" (not the other one !!). Morphs take the "max" value for the category "Mass" (the reset of the character before the operation is automatic). But the result is slightly different. Take another snapshot to see the differences.
    The problem here is that the engine does complex operations that I can't reproduce (it's beyond my competence). So the result is roughly good but far from exact.
    So that's means for the user that he must do his stuff, import the result and check it by playing with "age, mass & tone" cursors. It's a "try & error" process that could become tedious and annoying, but I don't know how to do things better for now.

@animate1978
Copy link
Owner

Well it is better than before, when we had no tools so it is ok.

I've been doing trial and error with the GUI and little success so I am sure I am missing something just haven't gotten it yet. I have to look over that patch again and see.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Mar 29, 2020

This is a special post, for the documentation. As always, bad english, and I'll edit it time to time.
So what's about ?

This addon was developed to create, rig, and animate various types of human, from a "root model". The difference with MakeHuman is that this older tool made by the same author, Manuel Bastioni start with only one model. No gender, you can evolve your model from baby to very old, and few other things. Cool, but brings a lot of problems (for genders especially) that Manuel didn't want for his new tool. And MakeHuman is a separated program, much more complicated to develop than an addon for a free program like Blender, especially when this program can compete with the best on the market, especially since version 2.79.

This introduction is a way to introduce the fact that the addon is more or less MH directly in Blender, using all stuff already done in Blender, so MB doesn't have to bother about. So that means that a large parts of MB just handle data that are used by Blender, and the only thing where MB focusing on is the handling of the model and links with Blender functions like rendering, hair, rig and so on.

In order to do that correctly, Manuel divided the use of his addon in 3 distinct steps :

  1. The setting of the scene where the character is created. If the user wants to use evee, the lights for rendering and so on.
    image
  2. The step of the creation of the character. Its gender, phenotypes, proportions and so on.
    image
  3. After finalization of the character, all tools for rigging, shaders, hair and so on. The user can't go back to change his model, at least with the addon's tools. All elements handled by the addon that can be handled by Blender are transferred to Blender elements, like shapekeys.
    image

So the user must understand that step 2 and 3 are clearly separated. More than this, you can do things in step 2 that you can't in step 3 and vice-versa. In fact, almost nothing can be done in both of them. So user must be aware of that and save his work during each step just in case.

So step 2 is the core of the program and can be resumed in one word : Morph.
Except skin textures, all is related to morphs and everything that is related to : vertices, shapes. BBoxes and vertices groups are important, but they are used only after finalization.

When the session starts, all data useful for step 2 and step 3 are loaded and can be roughly resumed like this :

  1. The user chooses the model (human, anime), gender in step 1 and initiate the character.
  2. During initialization of step 2, aside loading data useful for step 3 :
  • The model is loaded.
  • The morphs made for this model are also loaded. The are used for many things during the creation process.
  • 1st, the morphs are used first for the phenotypes (African, Caucasian, ...)
  • 2nd, they are also used to create variation of the body as a whole : Age, Mass, Tone. And they are also used to create presets, to help user.
    image
  • 3rd, again, the same morphs are available to the user to create his own character.
    That means that some body parts can be morphed 3 times by the same morphs (and the effects are cumulative on the final result)
    The other data handled by the engine are updated accordingly, the user doesn't have to worry about them. Skeleton, rigs, muscular system for poses and animation, expressions, ...
  1. You have some tools that save times, like a basic posing system, to watch the proportions of the model, smooth body, skin editor.
    image
    image
  2. You even have tools to create a bunch of characters with just few clicks, and with restrictions, in order to have the kind of variations you want :
    image
    image

Of course you can save your model (in a light-weighted json file). More explanations about the tools are available in the documentation. The thing that is important here is all this stuff must be done before finalizing the model and go to step 3. And all stuff is provided by the engine, not by Blender, its rule here is only to display the model. It's not the case in step 3.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Transformation Creator WIP) Morphs creation (Transformation Creator done) Mar 30, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

So, as I'm starting to think about my new tool, I was thinking also about my combined morph tool, that I didn't tested yet, especially because I'll need it for the new tool anyway.

So I started to test it and I did 2 very fast morphs to see what's going on when we combine them and how the engine handles them.

So first, I did my 2 morphs, one overlapping the other, of course, and did stupid shape but that's the point : see how it works. I did a pike and a bump with the morph tool, and saved them under a special file, f_af01_morphs_temp.json, because I'll combine them and after that I won't need them in their original form (separated morphs). Morphs under Body.
image
Bump maxi
image
Pick maxi. Don't show the combinations and min values (it's the same, but inside the body)
So, quit Blender, reopen it, and voilà, the morphs are available, and show the same thing as I sculpted before.
image

Now the juicy part. I open the combined morph tool. Choose to combine 2 morphs, use my pseudo for the name.
image
Then, without touching the morphs, but just doing combinations min/max (so 4 combination in total), I finalize the file.
Quit Blender, delete temp file, just keep teto file. Open Blender, create an African female.
First good new : the combined morphs are shown as separated :
image
After that I played with cursors and... nothing spectacular

So I don't think that the advantages of combined morphs are here. Tomorrow, I'll remake the combined file, but this time I'll sculpt combinations before saving, to see what's going on.
I think that the interest of combined morph is here : to add extra details that are impossible to have when the morphs are separated. But I'll check that tomorrow.
Below the 2 json files if you want to play with them. Careful : change af01 to af02 or move the file elsewhere if you don't want to use them both in the same time. Because the engine add the vectors of the same name, combined or not... Interesting behavior by the way.

morphs.zip

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Apr 2, 2020

So I did other tests tonight, and I think I nailed the thing.

What I did basically. I put the file "temp" with my 2 simple morphs (that overlap each over), then I took "min" for bump and "max" for pike :
001
Then I sculpted the 2 a little to have this :
002
Saved the morphs file, quit Blender and reopen it after deleting "temp" file.
Tried "Pick" and "Bump" in "Body", with min and max, aaaand what I sculpted shows again, as intended. Of course, if I have "Bump" in 0.5 (aka the neutral value) and Pike at max, the result is slightly different from the first test where morphs were separated :
image
The first morph was way more sharp, but it's normal, as the engine doesn't have the first separated 2 morphs no more.
So, for me, and maybe I'm wrong, but as far I investigated in order to make the tool, here how it works :

  • The combined morphs are combinations from simple morphs that overlap, and are in the same category.
  • For the most cases, it is used when morphs topic are too extreme to have good results when used separately. For example, mass (aka fat) and tone (aka muscle). If you use sliders Tone and Mass in their extremes, for morphs that are on the same body part, but one is for mass, other is for tone, the result would be ugly at worst, weird at best.
  • So the tool allows the user to make simple morphs, then combine them, OR sculpt directly each combination that look good, in order to have nice mix when using the addon.
  • You can combine up to 4 simple morphs, that means 16 different sculpts, from "min-min-min-min" to "max-max-max-max". When saved, and used by the engine, the morphs seem to be separated, but work together.
  • The user can sculpt the most silly morphs he wants, there's always a neutral point (0.5).

@animate1978
Copy link
Owner

The complexity is growing... not a bad thing, just something to note for myself.

@TetoTheSquirrelFox
Copy link
Contributor Author

I'm tired, and the tool(s) is not finished yet (@animate1978 , I pushed the commit to save files, just in case, but please wait until it's done), but here is a teaser :
image

What's this ?
If the addon is a success, and morphs grow, there will be a time where you'll have dozens of morph files dedicated for one model available, and sometimes user will have to manage them. Make compilations, delete some morphs, move others, and so on.
So the tool is made for these operations, copy, move, delete, rename and even make backups (with date). You can do all of that from a source to a destination, create new files if needed...

My only issue for now is :

  • You have to create a character even if you work on another morphs files than the model uses. That's because how Python in Blender is done.
  • Because of that, I watch and load every file in morph directory, so that increases the beginning before user can play. Not that much, but let say 2~3s. Could be annoying if other tools are added after that and do the same thing to starting time.

@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Apr 6, 2020

Quick update : This evening I did bugfixes (there were a lot!) and improvements in the code, simplification and so on. Now the end is near, the tools should be finished tomorrow (should...).

Anyway, @animate1978 , here is something that is relevant to be in documentation I think. Where exactly ? I don't know. In "known issues" maybe ? (below the separation)

About the use of drop-down lists:

  • There's a limitation in Blender, due to the way it works about drop-down lists used in GUI.
  • Let's say that we have 2 drop-down lists, the 2nd has its values driven by the 1st :
    image
  • The 1st can have 2 values, the 2nd has its values depending of the 1st:
    image
    image

Where is the problem ?

  • Imagine that at first you choice "Ethnic group" -> "m_ca01_morphs". The index of the 2nd list is 18
  • Now you change your mind, and decide to choice something in "Gender". You'll have this (below) and warning messages about the 2nd drop-down list.
    image
  • Don't panic, it's not bug, it's because of the way drop-down lists work : When you change the content of the component, it keeps in memory the index where it was before the update. So, if after the update, the list is shorter, the index will be out of the limit, and Blender will send lot of warning, but actually it doesn't crash. It just don't know what to show. So if you have this behavior, you just have to choose an item in the list. But don't wait, because if the content of the component is used later, and if it remains empty, it could crash the engine or stop to work properly.

@animate1978
Copy link
Owner

animate1978 commented Apr 7, 2020

This is great!

I did manage to get some warnings from Blender, doing what you described above. I was trying to do it purpose to see what would happen.
There is a difference between Blender 2.82 and 2.83 (alpha builds)... there is a lot more information being printed to the terminal output in 2.83, not sure why and honestly I like that because it gives a little more feedback like during creation of a character, in 2.83 there term output prints this ...

...
Morph Nose_NostrilSizeX_max duplicated while loading morphs from file
Morph Eyebrows_Ridge_max duplicated while loading morphs from file
Morph Eyebrows_Angle_max duplicated while loading morphs from file
Morph Chin_Tone_max duplicated while loading morphs from file
Morph Nose_NostrilDiam_min duplicated while loading morphs from file
Morph Head_Flat_min duplicated while loading morphs from file
Morph Chin_SizeZ_min duplicated while loading morphs from file
Morph Nose_BasePosZ_max duplicated while loading morphs from file
Morph Cheeks_ZygomPosZ_max duplicated while loading morphs from file
Morph Nose_WingBump_min duplicated while loading morphs from file
Morph Chin_SizeZ_max duplicated while loading morphs from file
Morph Jaw_Angle2_max duplicated while loading morphs from file
Morph Eyebrows_PosZ_min duplicated while loading morphs from file
...

Not sure if the duplication is intended. I think I have seen this before when creating the Anime characters.
Anyways I will be working on the docs for these tools very soon since you seem to be close to completing these.

@TetoTheSquirrelFox
Copy link
Contributor Author

Nope, it's not that. I figured that weeks ago, don't worry.
When the engine loads morphs, it loads many files where the morphs are. But if the same morph is in more than one file, it writes that.
They are just warnings, the engines accepts them anyway, and replaces the old one by the new one.
And typically, the anime model was clearly not finished, because many morphs are duplicated for a reason.

@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Transformation Creator done) Morphs creation (Copy/Move/Delete/Remame/Backup morphs tool done) Apr 8, 2020
@TetoTheSquirrelFox TetoTheSquirrelFox changed the title Morphs creation (Copy/Move/Delete/Remame/Backup morphs tool done) Morphs creation (Copy/Move/Delete/Rename/Backup morphs tool done) Apr 8, 2020
@TetoTheSquirrelFox
Copy link
Contributor Author

TetoTheSquirrelFox commented Apr 8, 2020

The Copy/Move/Delete/Rename/Backup morphs tool is done. I tested it, it looks functional and I didn't see bugs (I mean, after I fixed them ^^ )

@animate1978 and @everyone don't hesitate to test it (make backups before !) and tell me if there are bugs or things you don't like or should be improved.

image

I won't explain again how it works, the GUI didn't change much since my last explanations. But there's an addendum :

Tool limitations

  • When you copy/move morphs from a file to another, if the other file is a new file, it will not show up in drop-down list about input files. You have to quit Blender
  • When you rename, move or delete morphs, you have to reset/rescan first, then change input file and comeback to your file you're working on. It's not intended, but I didn't figure out how to change that yet. A workaround is to do "new general file" in Blender and create a new character.
  • If you rename a morph (one each time only), if you reset/rescan, it'll disappear from the items in the category. It's normal and due to the way Blender works. Short story, some variables must be created in the beginning of the session, and when the session is started, you can't change them anymore (or I didn't find how). All morphs' names are created at this moment and can't be changed after. So new ones created by the tool can't show up for this reason.
  • For the moment you can't create files for a whole gender. It's intended, as most of morphs inside are essentials for many objects in a model. Groups, bboxes, and so on.

Warnings

  • No undo with this tool. If you're not sure, make backups.
  • Reminder : There are 2 types of morphs : The simple, and the combined (combination of 2~4 simple ones). When you rename a combined morphs, be aware to rename it in the same way. Example : Torso_Mass-Tone_... wil becomes Torso_Whatever-YourChoice_... Rename it Torso_WrongChoice_... and engine will have bad behavior.
  • Also, don't forget that many morphs are essential for the engine, as they are used for other things like groups (used in muscles and measures), bboxes and so on. So use this tool wisely, and if you're not the creator of the base model, use it only when you do user-files management, fix duplicate names from different sources and so on. Don't touch any morphs if it's not necessary. There's a spelling mistake ? It doesn't matter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants