animate1978 / MB-Lab

MB-Lab is a character creation tool for Blender 4.0 and above, based off ManuelBastioniLAB
Other
1.77k stars 308 forks source link

Melanin Levels #293

Open ez-set opened 3 years ago

ez-set commented 3 years ago

Hi I'm working with a few people to create vertex groups to allow for variable melanin patch's on the body. Currently I have palms and soles underway. Some of the toplogy make clean edges tricky, such as the outsole of the foot.

I hope to have a set of vertex color groups to share with you for the master, but I'm having trouble transferring vertex col groups to the base meshes.

I look forward to hearing back as I feel this will be great addition. ) image

image

image Also, I'm new to communication on github.

animate1978 commented 3 years ago

That is something I haven't even thought about actually, I am wondering myself how to go about doing this.

ez-set commented 3 years ago

I'm doing it with vertex paint, making it a mask, then using it as a value input on the larger skin node group.

I can share .blend, also I made a palettes to pull skin color ranges from research driven color patches. It seems the current skin shader relies on 1 color map for color data that's routed through the node group, I hope that the addon can have additional values for describing the texture and tones of skin as well. I have begun work a little on procedural normals that can also be applied to the different body areas, rather than being locked to a normal map texture alone. These will be driven by vertex color data as well. This effort is for a group I'm working with called computer club. I will link their github a account when it's available. The file will be with them.

animate1978 commented 3 years ago

If you could share a blend that would be cool. I am interested in seeing how this can work.

The skin shader does use a single color map, depending on the base character selection, such as Afro, Caucasian etc...

ez-set commented 3 years ago

Don't they pull from the same texture map? With the respective "male, female" image file? Didn't think they have different images for phenotypes. Just one for all.

ez-set commented 3 years ago

Thanks for adding the labels, like I said I'm new here.

ez-set commented 3 years ago

image Vertex color groups - dark, light, base image dark vertex color - using only black and white image

Node setup very easy, the "Lighter" node is actually a vertex color node - just changed the name image Soles and palms solid view Lighting>flat Color>vertex

animate1978 commented 3 years ago

Don't they pull from the same texture map? With the respective "male, female" image file? Didn't think they have different images for phenotypes. Just one for all.

No actually there are technically 4 maps for each realistic human base type.

Afro, Caucasian, Asian and Latino all have a specific albedo map. For each sex, so the maps directory is quite um large at the moment.

So again your idea may come in handy for the future, regarding skin tones...

ez-set commented 3 years ago

Any reference on how to transfer the vertex color between meshes will be very helpful, instead of using my color palette I will swap between the different albedos. I'm planning on using my current setup for a workshop, I can only find confusing links to data transfer modifier.

Thanks.

ez-set commented 3 years ago

melanin vertex color gh.blend to the fork on my page - https://github.com/ez-set/MB-Lab blend still getting used to gh I've added a demo here with the vertex colors in their current state.

ldo commented 3 years ago

If you want to copy a vertex colour layer from one mesh to another, here is a simple Python script to do that, that you can run in Blender’s Text Editor:

import bpy

# change the names of the meshes and colour layers as appropriate
srcmesh = bpy.data.meshes["srcmesh"]
dstmesh = bpy.data.meshes["dstmesh"]
srcvertcolours = srcmesh.vertex_colors["srccolours"]
dstvertcolours = dstmesh.vertex_colors["dstcolours"]
# srcvertcolours and dstvertcolours are of type MeshLoopColorLayer
# <https://docs.blender.org/api/master/bpy.types.MeshLoopColorLayer.html>

if len(srcvertcolours.data) != len(dstvertcolours.data) :
    raise RuntimeError \
      (
            "meshes do not have same number of vertices: %d vs %d"
        %
            (len(srcvertcolours.data), len(dstvertcolours.data))
      )
#end if

for src, dst in zip(srcvertcolours.data, dstvertcolours.data) :
    dst.color[:] = src.color
#end for

You will need to change the names “srcmesh”, “dstmesh”, “srccolours” and “dstcolours” as appropriate. The script includes a check that both meshes have the same number of vertices, but it does not check that those vertices correspond in any way 😈.

ez-set commented 3 years ago

THANKS! src is source and dst is the mesh the data is being transferred to in assume. I'll give it a whirl. probably gonna update the base mesh vertex colors and host file on my repo if it works out. I do worry i added an edge or two trying to get the color separation, but the visible errors on the feet may mean they are still og.

Also looking at the textures, they look like the same exact texture but with the hue and contrast changed.

tahnks again

animate1978 commented 3 years ago

The textures of each base model (Caucasian, Afro etc...) were just simply altered from the single albedo map from Manuel's original source, I don't recall exactly how I changed them because it was quite some time ago.

There are only two base mesh for each sex, each have different vertex counts though...

This is from the character_config JSON file

"human_female_base": { "description": "Generate the human female template", "template_model": "MBLab_human_female", "template_polygons": "human_female_polygs.json", "name": "human_female_base", "vertices": 18210, "faces": 17288, "label": "Human female" }, "human_male_base": { "description": "Generate the human male template", "template_model": "MBLab_human_male", "template_polygons": "human_male_polygs.json", "name": "human_male_base", "vertices": 17996, "faces": 17074, "label": "Human male"

So I don't think that script would work if it needs the same vertex count.

But at the same time since there is only one female and male mesh, this also means that each base character will use the same vertex color map... so for instance the Caucasian base char will have the same vertex coloring as the Afro, as well as the Asian and Latino. The only difference would be the sex of each model.

As for GitHub, if you do any development please do so in the 'dev' branch as that is the most current one, the 'master' branch is considered the "release" version which is at 1.7.7... we are working on 1.7.8 in the 'dev' branch. Not a huge deal but it does make things tricky when merging and could possibly cause conflicts in the future.

I did take your file and checked it out though. Aside from the SubD modifier causing all sorts of wreckage on the model (I simply removed it) the vertex coloring you did seems pretty easy to replicate.

I have also been working on changing the skin shader so that it uses another vertex color map as the basis for skin tone, adjusting some of the nodes in the shader to make it work right.

I do like this idea and it will be used, maybe not for this upcoming release since I want to have this out by the end of the month but maybe for version 1.7.9? I do want to thank you again for such a brilliant idea!

ez-set commented 3 years ago

Thanks so much. I can get the master / dev sorted out

I think the vertex color will vary on the sex as expected. Possibly something that can be resolved in later releases with a "gender" slider as make human had.

Duplicating the vertex color wont be difficult, I hope that feedback from others will help produce a malleable template for the melanin and skin normals.

I rushed and sent the file sorry for the subdiv lol. I stripped the nodes before sending thanks for lookout them.

animate1978 commented 3 years ago

I kind of abandoned the vertex coloring in favor of using image maps... simply because you can get much better detail on the maps and are not restricted by the polygons. Sharp edges kind of put me off on the idea. I did try this back in the summer though, adding vertex color maps, it just kind of fell through the cracks and as I just said the edges of the polygons kind of put a damper on the idea. So using image maps would be ideal only because the maps would be smoother in appearance, rather than the jagged edges of polygons.

This is being worked on for the next version.

animate1978 commented 3 years ago

melanin_level_WIP_005 melanin_level_WIP_004 melanin_level_WIP_003 melanin_level_WIP_002 melanin_level_WIP_001

animate1978 commented 3 years ago

melanin_level_WIP_006

Had to start on the male map and also fixed the shader math on the blending type. Had used a Screen blending node, chaged it to Value instead which looks a LOT better.