vrm-c / UniVRM

UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.dev/en/ . 日本語 はこちら https://vrm.dev/

Home Page:https://vrm.dev/en

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpringBone does not work correctly if you change the model size, for example scale (8,8,8).

nvjob-dev opened this issue · comments

  • UniVRM version: 0.81.0
  • Unity version: Unity-2022.3 and other
  • OS: Windows 10

SpringBone does not work correctly if you change the model size, for example scale (8,8,8).
The parameters depend on the size of the model, and there is no way to adjust this.
The bones themselves also behave incorrectly at the start, as if they were abruptly transferred from one position to another position (similar to a sharp fall).
Video with the problem:
https://www.youtube.com/watch?v=tWcA9wZiPzo
https://www.youtube.com/watch?v=BeJZDk62_UY

I managed to solve the problem. I'm not sure if this is correct. But it works well.
This is an example of solving the problem for - scale (8,8,8). For VRM1.

In file - UpdateFastSpringBoneJob

var nextTail = currentTail
               + (currentTail - prevTail) * (1.0f - joint.dragForce) // 前フレームの移動を継続する(減衰もあるよ)
               + parentRotation * logic.localRotation * logic.boneAxis *
               joint.stiffnessForce * DeltaTime // 親の回転による子ボーンの移動目標
               + external; // 外力による移動量

Replaced by

var nextTail = currentTail + (currentTail - prevTail) * ((1.0f/8.0f) - joint.dragForce) + parentRotation * logic.localRotation * logic.boneAxis * joint.stiffnessForce * DeltaTime * 8.0f + external;

The idea is to use the size of the model (8 in this example) as a factor.

https://www.youtube.com/watch?v=rabqs_TKr6g

For VRM0.
This is an example of solving the problem for - scale (8,8,8).

VRMSpringBone.cs

var stiffness = m_stiffnessForce * deltaTime ;
Replaced by
var stiffness = m_stiffnessForce * deltaTime * 8;

var nextTail = currentTail
                               + (currentTail - prevTail) * (1.0f - dragForce) // 前フレームの移動を継続する(減衰もあるよ)
                               + ParentRotation * LocalRotation * m_boneAxis * stiffnessForce // 親の回転による子ボーンの移動目標
                               + external; // 外力による移動量

Replaced by

var nextTail = currentTail
                               + (currentTail - prevTail) * ((1.0f/ 8) - dragForce) // 前フレームの移動を継続する(減衰もあるよ)
                               + ParentRotation * LocalRotation * m_boneAxis * stiffnessForce // 親の回転による子ボーンの移動目標
                               + external; // 外力による移動量

For myself, I did this, added a new scale_model variable, outputting it to the editor in the VRMSpringBoneEditor.cs script.

Please make the changes correctly in the next version of the asset. Thank you.