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

SkinnedMesh: Fix a vertex warping issue under negative weight #15303

Closed
wants to merge 1 commit into from

Conversation

0b5vr
Copy link
Collaborator

@0b5vr 0b5vr commented Nov 22, 2018

I'm curretnly working on glTF stuff using THREE.GLTFLoader.
Sometimes SkinnedMesh accidentally has negative bone weights, and such models does weird behavior on Three.js, while most of other environments are not.
It's since Three.js is using 1.0 / Vector4.manhattanLength() when normalizing these weights.
I know negative weights are generally invalid in most of situation, but it seems most of applications has different procedure from calculating manhattan length: just using sum of all weights.

@0b5vr 0b5vr changed the title SkinnedMesh: Fix an vertex warping issue under negative weight SkinnedMesh: Fix a vertex warping issue under negative weight Nov 22, 2018
@donmccurdy
Copy link
Collaborator

Negative weights in glTF are definitely invalid — from the conclusion of that thread, and the spec:

The joint weights for each vertex must be >= 0, and normalized to have a linear sum of one.

If there is a tool creating negative weights, I'd recommend filing a bug about that.

Are you trying to get a certain behavior here? With or without this change, it doesn't seem like the result will be particularly meaningful.

@0b5vr
Copy link
Collaborator Author

0b5vr commented Nov 22, 2018

If there is a tool creating negative weights, I'd recommend filing a bug about that.

Yeah definitely, I know (and honestly it tried to prevent me from issue this pr), but in either way the current way how Three.js deals with such situation doesn't match to other "standard" idea. 😥

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 22, 2018

The formula for the manhatten length is correct since it's the sum of the absolute differences of their coordinates and I think it's valid to use it in context of skin weights.

I do not vote to merge this PR.

@0b5vr
Copy link
Collaborator Author

0b5vr commented Nov 22, 2018

The formula for the manhatten length is correct

No, there are no correct way to deal with negative weights since negative weights are invalid

In anyway I don't get the current way how we're dealing with negative bones, no validations AND different result from other environments, I got really confused by this behavior yesterday (I took a full day to solve this).

...I'm beginning to be embarrassed about starting this discussion as a pr 😅

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 22, 2018

No, there are no correct way to deal with negative weights since negative weights are invalid

I've referred to the manhatten length. It's formula is definitely correct (see https://en.wikipedia.org/wiki/Taxicab_geometry).

@donmccurdy
Copy link
Collaborator

@fms-cat No need to feel embarrassed, it's a good question and we've had to clarify the glTF spec on this before. I think your point that there is no correct way to deal with negative weights is right. I prefer the simplicity of using the existing manhattanLength method, since what other tools do here is no more correct than our solution. Arguably the most "correct" thing to do would be to throw an error.

When you test the model on https://gltf-viewer.donmccurdy.com/ or http://github.khronos.org/glTF-Validator/, do you see a warning about the negative weights? If not, I think the best step would be to ensure these tools show a warning.

@donmccurdy donmccurdy closed this Nov 22, 2018
@donmccurdy
Copy link
Collaborator

Thanks for finding the issue for the PR, and sorry it was more complicated than expected. :)

@0b5vr 0b5vr deleted the dev-skinning-negativeweight branch November 26, 2018 01:03
@0b5vr
Copy link
Collaborator Author

0b5vr commented Nov 26, 2018

@donmccurdy Thanks too! As you said it's more than I expected 😖

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

3 participants