Skip to content

Commit

Permalink
set maximum value for BlendShapes #63.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Mar 30, 2024
1 parent 9fdf7ca commit 24266f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Editor/uLipSyncBlendShapeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public override void OnInspectorGUI()
if (EditorUtil.Foldout("Blend Shapes", true))
{
++EditorGUI.indentLevel;
EditorUtil.DrawProperty(serializedObject, nameof(blendShape.maxBlendShapeValue));
DrawBlendShapeReorderableList();
--EditorGUI.indentLevel;
EditorGUILayout.Separator();
Expand Down
5 changes: 3 additions & 2 deletions Runtime/uLipSyncBlendShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class BlendShapeInfo
public UpdateMethod updateMethod = UpdateMethod.LateUpdate;
public SkinnedMeshRenderer skinnedMeshRenderer;
public List<BlendShapeInfo> blendShapes = new List<BlendShapeInfo>();
public float maxBlendShapeValue = 100f;
public float minVolume = -2.5f;
public float maxVolume = -1.5f;
[Range(0f, 0.3f)] public float smoothness = 0.05f;
Expand Down Expand Up @@ -169,7 +170,7 @@ protected virtual void OnApplyBlendShapes()
{
if (bs.index < 0) continue;
float weight = skinnedMeshRenderer.GetBlendShapeWeight(bs.index);
weight += bs.weight * bs.maxWeight * volume * 100;
weight += bs.weight * bs.maxWeight * volume * maxBlendShapeValue;
skinnedMeshRenderer.SetBlendShapeWeight(bs.index, weight);
}
}
Expand Down Expand Up @@ -222,7 +223,7 @@ public override List<float> GetPropertyWeights()
foreach (var bs in blendShapes)
{
if (bs.index < 0) continue;
var weight = bs.weight * bs.maxWeight * volume * 100f;
var weight = bs.weight * bs.maxWeight * volume * maxBlendShapeValue;
weights.Add(weight);
}

Expand Down

0 comments on commit 24266f8

Please sign in to comment.