From ee4f3a0db4570c3e98346003409609be3944e05e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 21 Oct 2024 19:10:30 +0900 Subject: [PATCH] impl expression binary and override combination https://github.com/vrm-c/vrm-specification/pull/487 --- .../Expression/DefaultExpressionValidator.cs | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10/Runtime/Components/Expression/DefaultExpressionValidator.cs b/Assets/VRM10/Runtime/Components/Expression/DefaultExpressionValidator.cs index b671a16087..167bd6b256 100644 --- a/Assets/VRM10/Runtime/Components/Expression/DefaultExpressionValidator.cs +++ b/Assets/VRM10/Runtime/Components/Expression/DefaultExpressionValidator.cs @@ -69,21 +69,52 @@ public void Validate(IReadOnlyDictionary inputWeights, IDi var blinkMultiplier = 1f - blinkOverrideRate; var lookAtMultiplier = 1f - lookAtOverrideRate; var mouthMultiplier = 1f - mouthOverrideRate; + Debug.Log($"m{mouthMultiplier} b{blinkMultiplier} l{lookAtMultiplier}"); // 3. Set procedural key's weights. foreach (var key in _keys) { if (key.IsBlink) { - actualWeights[key] = actualWeights[key] * blinkMultiplier; + if (_expressions[key].IsBinary) + { + if (blinkMultiplier < 1.0f) + { + actualWeights[key] = 0.0f; + } + } + else + { + actualWeights[key] = actualWeights[key] * blinkMultiplier; + } } else if (key.IsLookAt) { - actualWeights[key] = actualWeights[key] * lookAtMultiplier; + if (_expressions[key].IsBinary) + { + if (lookAtMultiplier < 1.0f) + { + actualWeights[key] = 0.0f; + } + } + else + { + actualWeights[key] = actualWeights[key] * lookAtMultiplier; + } } else if (key.IsMouth) { - actualWeights[key] = actualWeights[key] * mouthMultiplier; + if (_expressions[key].IsBinary) + { + if (mouthMultiplier < 1.0f) + { + actualWeights[key] = 0.0f; + } + } + else + { + actualWeights[key] = actualWeights[key] * mouthMultiplier; + } } }