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

Possible fix to include normalized BlendShape weights #63

Open
HunterProduction opened this issue Feb 20, 2024 · 3 comments
Open

Possible fix to include normalized BlendShape weights #63

HunterProduction opened this issue Feb 20, 2024 · 3 comments
Assignees

Comments

@HunterProduction
Copy link

Hi @hecomi!

Thank you for this useful and well made tool. While trying to use it for my application, when I first tested it the result on my avatar was, lets say, "overshooted"! Looking at your uLipSyncBlendShape code, specifically the OnApplyBlendShapes() method, I noticed that you compute the final weight value as follows:

weight += bs.weight * bs.maxWeight * volume * 100;

Since maxWeight, weight and volume should be normalized values between 0 and 1, the output weight you are providing is in the form of a percentage (from 0 to 100). At least for the avatar that I'm currently using, taken from ReadyPlayerMe tool, it seems that the blendshape weights for the SkinnedMeshRenderer are meant to be normalized values, between 0 and 1. That is why the first test of the tool applied to my avatar results in a deformed and "broken" mesh.

To fix this, I simply added another serialized bool to your script, called useNormalizedBlendShapeWeights, and I added a simple line of code in the OnApplyBlendShapes(), in this way:

weight += bs.weight * bs.maxWeight * volume * 100;
if (useNormalizedBlendShapeWeights) weight /= 100f;  // Keep weight normalized between 0 and 1

Please let me know if this fix actually makes sense to you! I hope that this could help improve compatibility with more types of avatars.

Thanks again!

@hecomi
Copy link
Owner

hecomi commented Mar 30, 2024

Sorry for the delayed response, and thank you for your feedback and for diving into the code! I primarily work with avatars that use a 0 to 100 scale for blendshape weights, which is why the script is designed that way. However, I understand the need for compatibility with avatars that use normalized 0 to 1 values, like the one from ReadyPlayerMe. Your suggestion to add an option to use normalized blendshape weights makes perfect sense, and I'll definitely consider implementing a feature to support both types of avatars. Your input is very valuable in making the tool more versatile and user-friendly. Thanks again!

@hecomi hecomi self-assigned this Mar 30, 2024
hecomi added a commit that referenced this issue Mar 30, 2024
@hecomi
Copy link
Owner

hecomi commented Mar 30, 2024

I've made it possible to set the maximum value for BlendShape values to make it more versatile. By default, this is set to 100, so please try setting it to 1.

Screen Shot 2024-03-30 at 22 57 13

github-actions bot pushed a commit that referenced this issue Mar 30, 2024
@hecomi
Copy link
Owner

hecomi commented Mar 30, 2024

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

2 participants