cc_blender_tools icon indicating copy to clipboard operation
cc_blender_tools copied to clipboard

Import materials and apply original if available

Open schroef opened this issue 1 year ago • 10 comments

I just saw this great addon on CGDive youtube channel. He showed a great use case for this add-on. One thing i noticed is that there is no option when importing, to check for existing materials. Currently it adds all materials as copies. It would be great if it could find use available mats.

I can try to make this adjustment myself and pull request

schroef avatar Sep 09 '22 18:09 schroef

Since version 1.4.3 it does. (It's an option in the Character Build Panel, but it's on by default) It's a de-duplication process, so any textures that are identical are re-used rather than duplicated, then any materials with the same name, that use the same textures and have the same parameters are re-used rather than duplicated. Any differences will force a new material.

The exports from CC3/4 export all materials on each object as if they are unique with their own parameters and textures sets. So de-duplication is the only real way to consolidate textures and materials in Blender.

soupday avatar Sep 09 '22 21:09 soupday

Ok, watched the video I see what you meant.

There's a lot of pitfalls to that, namely both Blender and AccuRig renaming materials and object/mesh names (namely duplication suffixes and selective underscore replacements), which causes problems for matching names.

Fortunately it seems that AccuRig follows the same renaming conventions as Character Creator and iClone which I already know how to deal with, so it's a relatively simple task to match these modified source names with existing objects and materials.

I've made a preliminary operator function to do this matching. It's in the Utilities panel of the CC/iC Create Tab and I've put a button in the Rigify panel in the info box (when the character is detected as ActorCore)

It's in the Dev branch: https://github.com/soupday/cc_blender_tools/tree/Dev

https://github.com/soupday/cc_blender_tools/blob/Dev/characters.py#L729

Works so far on what I've tested but it could do with more testing.

soupday avatar Sep 10 '22 19:09 soupday

Thanks for the fast reply!

I guess it happened when he exported it initially and the dot named materials got their underscore. Ill test that model he showed and see where it happens

thanks for the headsup on that dev branch

schroef avatar Sep 10 '22 19:09 schroef

Reallusion's software doesn't like dots in the mesh/material names so it always replaces them with underscores. Also, I discovered only a few weeks ago, that if the material name starts with a digit, that digit gets replaced with an underscore too.

Causes havok with name matching.

soupday avatar Sep 10 '22 19:09 soupday

"I've made a preliminary operator function to do this matching. It's in the Utilities panel of the CC/iC Create Tab and I've put a button in the Rigify panel in the info box (when the character is detected as ActorCore)"

what is the name of this operator if may ask?

schroef avatar Sep 10 '22 19:09 schroef

Reallusion's software doesn't like dots in the mesh/material names so it always replaces them with underscores. Also, I discovered only a few weeks ago, that if the material name starts with a digit, that digit gets replaced with an underscore too.

Causes havok with name matching.

So user needs make it a habbit of properly naming meshes and materials so they get imported correctly in return. Ill make a comment about that below his video/

schroef avatar Sep 10 '22 19:09 schroef

It's part of the CC3OperatorCharacter (id "cc3.character")

https://github.com/soupday/cc_blender_tools/blob/Dev/characters.py#L804

soupday avatar Sep 10 '22 19:09 soupday

So user needs make it a habbit of properly naming meshes and materials so they get imported correctly in return. Ill make a comment about that below his video/

To be safe, yes. Well named objects/meshes/materials should guarantee successful results.

soupday avatar Sep 10 '22 20:09 soupday

Really appreciate you guys even replying over the weekend!!!

i added the info about the material to his video,. hope it helps others

schroef avatar Sep 10 '22 20:09 schroef

It's part of the CC3OperatorCharacter (id "cc3.character")

https://github.com/soupday/cc_blender_tools/blob/Dev/characters.py#L804

So its the match_materials operator i guess

schroef avatar Sep 10 '22 20:09 schroef