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

[API Behaviour Breaking Change] Don't change raw blendshapes immediately when calling Vrm10RuntimeExpression.SetWeights() #2130

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

Santarh
Copy link
Contributor

@Santarh Santarh commented Aug 15, 2023

現在 Vrm10RuntimeExpressionSetWeights() SetWeightsNonAlloc() SetWeight() は呼び出すと即時、Expression の設定に従って SkinnedMeshRenderer の BlendShape 等が変化するように反映します。

この挙動は直感的に思えますが、実は他の Vrm10 要素と一貫性がなく、なによりパフォーマンスボトルネックになっています。

一貫性の無さとして ControlRig Constraint LookAt の他の Vrm10Runtime 要素は即時反映ではないことが挙げられます。
これらはデフォルトでは LateUpdate で呼び出される Vrm10RuntimeProcess() において反映されます。

public void Process()
{
// 1. Control Rig
ControlRig?.Process();
// 2. Constraints
foreach (var constraint in Constraints)
{
constraint.Process();
}
// 3. Gaze control
LookAt.Process(m_target.LookAtTargetType, m_target.LookAtTarget);
// 4. Expression
Expression.Process();
}

またパフォーマンスボトルネックとしては、1フレーム中において

  • 「ユーザが Vrm10RuntimeExpression.SetWeights() を呼び出したとき」
  • 「LateUpdate で Vrm10Runtime.Process() が呼び出されるとき」
    の 2 回、反映処理が走ってしまうことがかなりネックになっています。

今回の挙動変更を行うことで、次のような変化が起きます。

  • メリット Pros
    • 多くのユーザアプリケーション実装において、特に挙動を変えずに Expression 反映という実は重めの処理を半減させることができます。
    • 他の ControlRig, Constraint, LookAt が即時反映ではないことと一貫性のある挙動になります。
  • デメリット Cons
    • 一部のユーザアプリケーション実装で挙動が変わります。
      • ユーザによる Vrm10RuntimeExpression.SetWeights() 呼び出しタイミングが Vrm10Runtime.Process() の実行よりも遅い場合

@Santarh Santarh requested a review from ousttrue August 15, 2023 12:32
@Santarh Santarh changed the title [API Breaking Change] Don't change raw blendshapes immediately when calling Vrm10RuntimeExpression.SetWeights() [API Behaviour Breaking Change] Don't change raw blendshapes immediately when calling Vrm10RuntimeExpression.SetWeights() Aug 15, 2023
Copy link
Contributor

@ousttrue ousttrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply() を1フレーム一回にしたい

@Santarh Santarh merged commit b74f28a into vrm-c:master Aug 16, 2023
1 check passed
@Santarh Santarh deleted the expressionBreaking branch August 16, 2023 03:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants