soupday / cc_unity_tools_URP

Package for importing and auto setup of Character Creator (3 & 4) and iClone (7 & 8) character exports for Unity URP Pipeline.
GNU General Public License v3.0
104 stars 26 forks source link

Wrinkles manager nog working properly? #56

Open koffertje opened 8 months ago

koffertje commented 8 months ago

it looks like the default wrinkle manager does not work properly? especially not when a character smiles.

image

soupday commented 8 months ago

Keep in mind CC4's sliders go to 150, Unity's only go to 100. You'll have to type in 150 into the blendshape value to go above 100, (or below 0 for that matter).

koffertje commented 8 months ago

that is true indeed but still. this screenshot is 100 now. image

but also with the enabled and disabled wrinkle manager there is not difference on the sides of the mouth

liudger commented 6 months ago

I have this issue once in a while too. Sometimes these are not setup image It looks like it is already missing in the imported FBX files that is build. Not sure what causes this issue. Maybe a postprocessor?

liudger commented 6 months ago

Could be if it is not installed as package?

private void ApplyWrinkleMasks(Material mat)
        {
            string[] folders = new string[] { "Packages", fbmFolder, texFolder };

            string[] maskNames = new string[] { "RL_WrinkleMask_Set1A", "RL_WrinkleMask_Set1B", "RL_WrinkleMask_Set2", "RL_WrinkleMask_Set3", "RL_WrinkleMask_Set123" };
            string[] refNames = new string[] { "_WrinkleMaskSet1A", "_WrinkleMaskSet1B", "_WrinkleMaskSet2", "_WrinkleMaskSet3", "_WrinkleMaskSet123" };

            for (int i = 0; i < maskNames.Length; i++)
            {
                string maskName = maskNames[i];
                string refName = refNames[i];
                Texture2D tex = Util.FindTexture(folders, maskName);
                if (tex)
                {
                    mat.SetTextureIf(refName, tex);
                }
            }            
        }
liudger commented 6 months ago

It looks like this is indeed the problem. I'll create a pull request with a fix. (Not sure if this is the best fix)

liudger commented 6 months ago

This fix worked for me. Let me know if it solved your issue or that I just hijacked you thread ;) @koffertje

59

ps @soupday can you check the pull request thanks 👍

koffertje commented 6 months ago

@liudger nice. im going to check it out later!

liudger commented 6 months ago

There is also sometimes an issue with the material not being updated in the wrinkle manager. This is in runtime. image

void Start()
        {
            updateTimer = 0f;

            if (Application.isPlaying)
            {
                SkinnedMeshRenderer smr = GetComponent<SkinnedMeshRenderer>();
                if (smr)
                {
                    foreach (Material mat in smr.materials)
                    {
                        if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON"))
                        {
                            headMaterial = mat;
                            break;
                        }
                    }
                }
            }

            CheckInit();            
        }

It should be updated on start. Not yet sure why sometimes it doesn't update. Probably bool is not set on material

liudger commented 6 months ago

I guess this is an issue with baking. I can't find the function that copy the keyword. The keyword BOOLEAN_USE_WRINKLE_ON does exist. We could use this? @soupday

void Start()
        {
            updateTimer = 0f;

            if (Application.isPlaying)
            {
        // print keywords headMaterial
        Debug.Log("Keywords: " + string.Join(", ", headMaterial.shaderKeywords));
                SkinnedMeshRenderer smr = GetComponent<SkinnedMeshRenderer>();
                if (smr)
                {
                    foreach (Material mat in smr.materials)
                    {
            // check for keyword BOOLEAN_IS_HEAD_ON or BOOLEAN_USE_WRINKLE_ON
                        if (mat.IsKeywordEnabled("BOOLEAN_IS_HEAD_ON") || mat.IsKeywordEnabled("BOOLEAN_USE_WRINKLE_ON"))
                        {
                Debug.Log("Found head material");
                            headMaterial = mat;
                            break;
                        }
                    }
                }
            }

            CheckInit();            
        }
soupday commented 6 months ago

The material properties are copied from template materials. But the baking system doesn't really distinguish between the head material and the body materials, unless wrinkle maps are enabled and it has the wrinkle map keywords.

BOOLEAN_USE_WRINKLE_ON should exist if wrinkle maps are enabled on the character.

Might be an idea to copy the BOOLEAN_IS_HEAD_ON keyword at the end of BakeSkinMaterial in ComputeBake for completeness.

kwahu commented 5 months ago

Hi guys, I'm trying to import a character with wrinkles, I tried the release, the main and dev branches and neither helped. THe result is that the prefab has Std_Skin_Head material as URP/Lit :( all other ones have Amplify/RL_SkinShader_Variants_URP Also there seems to be no code in the prefab that would handle sync of the material with the animation data

help

liudger commented 5 months ago

I think this a different issue. When import the character head should have -> RL_Amplify_SkinShader_Variants_URP And when baked -> RL_Amplify_HeadShaderWrinkle_Baked_URP So maybe the export from Reallusion is not done right? https://soupday.github.io/cc_unity_tools/expression-wrinkles.html?highlight=wrinkle

kwahu commented 5 months ago

I found the problem, for the face I was using "Traditional" shader in CC4, and the Unity importer looks for the original "skin" shader, so it's something to consider to be more robust on the importer side, to accept the wrinkles indepnedent on the shader set in CC4. I'm working on a animelike charater with wrinkles ;)

liudger commented 4 months ago

@kwahu The shader needs to be specific to work. Wrinkles is a shader feature. So you can't select a random shader and have wrinkles.