Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrinkles manager nog working properly? #56

Open
koffertje opened this issue Mar 21, 2024 · 14 comments
Open

Wrinkles manager nog working properly? #56

koffertje opened this issue Mar 21, 2024 · 14 comments

Comments

@koffertje
Copy link

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

image

@soupday
Copy link
Owner

soupday commented Mar 21, 2024

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
Copy link
Author

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
Copy link
Contributor

liudger commented May 28, 2024

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
Copy link
Contributor

liudger commented May 28, 2024

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
Copy link
Contributor

liudger commented May 28, 2024

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
Copy link
Contributor

liudger commented May 28, 2024

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
Copy link
Author

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

@liudger
Copy link
Contributor

liudger commented May 29, 2024

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
Copy link
Contributor

liudger commented May 29, 2024

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
Copy link
Owner

soupday commented May 29, 2024

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
Copy link

kwahu commented Jun 24, 2024

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
Copy link
Contributor

liudger commented Jun 25, 2024

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
Copy link

kwahu commented Jun 25, 2024

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
Copy link
Contributor

liudger commented Jul 8, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants