Helpful Blender Scripts - shapekey transfer and material slot combiner
Below are a couple of Blender scripts I put together to help speed up my workflow while working with Daz3d characters.
They are set up for Genesis 8 characters but can be modified to fit your needs. They should work with 2.80 or 2.81
The first combines all the material slots that use the same texture, removes the unused material slot names, renames pupils to eyes, and shortens long names like Genesis8FemaleEyelashes_EyeMoisture to Eyelash_Moisture
The second script can be used to transfer shapekeys from one object to another (Object have to have the same poly count as usual)
It is also set up to remove the "Genesis8Female__" or "Genesis8Male__" from the beginning of the shapekey names.
No need to install these anywhere. In Blender click on the Scripting tab, under Text, select New, and paste the code in.
Make any changes in the script for your character and hit Run Script
To see the progress of the script click on the Blender Window menu, and select Toggle System Console
If you have any questions, feedback or ways the script could be improved please let me know.
Comments
Thanks for sharing your scripts. As they are designed for your own workflow, could you expand on what that is, in particular how you transfer your Daz characters into Blender, and where the scripts fit into your workflow? That would be useful in understanding how and when these scripts will help the rest of us.
Hi, thanks for this contribution. If I understand correctly, the first script would be extremely useful with the way that the Diffeomorphic plugin works, which sometimes results in many identical materials with the same same, e.g. material.001, .002, etc...
Will you put this somewhere like GitHub? I have some scripts I use to re-texture objects imported via Alembic; we could grow this into a suite of useful Daz-To-Blender tools...
Sorry for the post and ghost. I wanted to put together a quick overview of my workflow and where these scripts fit in. It took longer than I thought.
I should probably make another whole post just for details if anyone is interested. It's has been a little while since I did these from start to finish, details are a bit rusty.
I start with the Basic Male or Female character and add any geografts I might need,
I save copies with default UVs, and 2nd UVs if available. Then I use the Diffeomorphic Daz to Blender plugin to export and save a copy too.
I then merge fitted figure's geometry, delete the extra meshes that are created and convert the character back to SubD if needed.
In 4.11 and 4.12 there is a bug that makes the eyelashes disappear. I did submit the bug, hopefully it will get fixed.
I export the character as an FBX file 4 times
1 Base resolution UV1 no morphs (Base Poly)
2 Base resolution UV2 no morphs (Base Poly)
3 Subdivision 1, UV1, with Mouth Open, and Eyes Closed Morphs (1Subdivision Poly)
4 Subdivision 1, UV2, no morphs (1Subdivision Poly)
In Blender
I import the 1Sub Poly first then the Base Poly next.
I remove the eyes from both ( I think i used a script for this too)
I apply a subdivision modifier on the Base Poly mesh, then transfer mesh data - vertex groups - to copy weight paints to the 1Sub Poly mesh.
There is a lot of cleanup to do after this as some of the weight paint get copied to the wrong vertex if they are too close.
Mostly around the mouth and eyelids, but also around the toes. Having the mouth open and eyes closed morphs helps when the rigging isn't working right.
Once I am happy with the cleanup efforts I import the 2nd uv character and transfer UV's to the one with UV1
I now have a 1 Subdivided Poly Daz model, fully rigged, with multiple UV channels.
Back in Daz Studio I start exporting my purchased characters.
I will dial in Aiko and click Currently Used in the shaping tab to see what morphs are applied to her.
I will dial out the Aiko Character morph and reapply the Body and Head morphs. This will make the head and body the correct shape but not adjust the size. Important for animations.
Can be resized later with math and stuff)
Add geografts, Save file and export and save using the Diffeomorphic Plugin
I Merge fitted figures like before, remove extra geometry, convert back to SubD if needed
Export FBX 2 times. 1Sub Poly with no morphs and one with any morphs you want to have.
Then I open the 1 Sub Poly Basic Character file was working with and import the 1Sub Poly -no morph Aiko. Remove Eyes, Join as shape to apply Aiko Morph to Basic Female character then remove the Basis Shapekey.
I now have Aiko with all the 1Sub Poly, with Weight Paint and 1st and 2nd UV info.
Import Aiko into Blender using the Diffeomorphic plugin and run the Bone uitility to orientate the bone rolls correctly. Save Blender file.
Back in the 1Sub Poly Aiko file, append the Rig from the Diffeomorphic file and parent the 1Sub Poly Aiko mesh to her correctly sized and orientated rig.
Almost done. I Import Aiko 1Sub Poly with all her morphs, remove eyes then (here it is!!!!) run the transfer shapekeys script to copy all the shapekeys to your characters and shorten the names to remove the "Genesis8Female__" part
Save a file as backup.
I will usually run the Material Script last and save as a separate "finished" file as it cannot be easily undone. It merges together material slots that are using the same texture.
Why is this important? In Blender and Unreal Engine 4 it is not necessary to have a separate material slots for the the Face, Lips, Ears, and EyeSocket especially if they are using the same texture. You can still achieve the same results of being able to change the lip colors or even textures applied to the ears by using masks instead. Also in Unreal Engine there is a cost per material slot you have in as scene so keeping the amount of slots to a minimum can help performance.
As always I look forward to any feedback or ideas.
That's great! The original idea of the script was to just combine material slots, remove the unused ones, and rename some annoying long ones, but you are right. You should be able to enter the names of the material slots with the .002 on them and instruct the script what you would like them to be named instead. Save and run the script anytime you need these changed.
I was originally thinking Github but I wasn't sure anyone would bother going there, downloading or copying the scripts, and trying them so I put it right in the forum to make it as easy as possible.
Having a central place for these little helpful little scripts and fixes would be great, maybe with a link back to the Daz forums for discussion and updates.
Wow, that is quite some workflow! Thanks for writing it all up. I do use the Daz Importer ('Diffeomorphic') plug-in, but i am not targeting Unreal so have found the plugin's 'Merge Materials' option adequate for my purposes thus far. However, I will bookmark your scripts for possible future use.
I have needed this in pretty much every 3d package I've ever used, so thank you very much.
I'm glad you found that script helpful. I have started dabbling in Daz scripting and have been wondering if this can be done in Daz Studio. That way it could be helpful in whatever 3d program you are exporting to.
If I figure it out I will post the script.
Thank you so much for sharing your scripts, they have been very useful.
You're welcome.
I found an issue with the Material Slot combiner. If the last material slot is removed it causes the script to fail. I fixed it above.
I'm finally getting around to getting these and other scripts to my Github repositories and adding documentation.
Material Slot Combiner
https://github.com/GNVR-Dev/BlenderScripts-Daz-Material-Slot-Combiner
Shapekey Transfer
https://github.com/GNVR-Dev/BlenderScripts-Daz-Shapekey-Transfer
Awesome tools, thanks so much for sharing!