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

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

Open
nvjob-dev opened this issue Feb 8, 2024 · 3 comments
Labels
bug Something isn't working SpringBone

Comments

@nvjob-dev
Copy link

nvjob-dev commented Feb 8, 2024

  • 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

@nvjob-dev nvjob-dev added the bug Something isn't working label Feb 8, 2024
@nvjob-dev
Copy link
Author

nvjob-dev commented Feb 8, 2024

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

@nvjob-dev
Copy link
Author

nvjob-dev commented Feb 8, 2024

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.

@ousttrue ousttrue added this to the v0.122 milestone Mar 19, 2024
@ousttrue
Copy link
Contributor

@ousttrue ousttrue modified the milestones: v0.122 ktx2 y-flip, v0.123 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SpringBone
Projects
None yet
Development

No branches or pull requests

2 participants