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

Mesh deformation #915

Open
WollieWoltaz opened this issue Dec 24, 2020 · 31 comments
Open

Mesh deformation #915

WollieWoltaz opened this issue Dec 24, 2020 · 31 comments
Assignees
Milestone

Comments

@WollieWoltaz
Copy link

WollieWoltaz commented Dec 24, 2020

Hello,

I'm encountering some strange mesh deformation when exporting with the latest version of the glTF exporter for 3dsMax 2021.
Only a specific part of the mesh get's deformed everything else seems to look good in the online sandbox babylon viewer.
There are a couple of errors/warnings but i'm not sure what those mean...

Here are 2 examples of 2 different characters who encounter a similar issue. I included the .FBX and glTF format:
(Link Deleted)

1st character animation comparison:
3dsMax 2021:
https://user-images.githubusercontent.com/19957561/103104326-c30c5900-4626-11eb-922d-b85d42f03d69.mp4
glTF viewer:
https://user-images.githubusercontent.com/19957561/103104338-d7e8ec80-4626-11eb-86e4-9b9bad92f80f.mp4

(The scroll that he holds in his hand is getting deformed)

2nd character animation comparison:
3dsMax 2021:
https://user-images.githubusercontent.com/19957561/103104371-08308b00-4627-11eb-91e6-8bca1d51d0fb.mp4
glTF viewer:
https://user-images.githubusercontent.com/19957561/103104379-141c4d00-4627-11eb-95e4-1a071c066386.mp4

(The tongue is getting deformed)

Is this something that can be fixed in the export script from 3dsMax to glTF/glb?

Regards,

@WollieWoltaz
Copy link
Author

Sorry for bumping this topic but i'd really like to know why this happens and if i can fix this manually before exporting? Or is this something that can be fixed in the glTF exporter?

Regards,

@pandaGaume
Copy link
Contributor

Sorry for the delay, we were working on another topic and had limited bandwidth. I took a look at the scene and it's quite a difficult issue to follow due to the "complexity" of the scene. Are you able to reproduce it if you isolate the tongue that is involved?

@WollieWoltaz
Copy link
Author

WollieWoltaz commented Jan 18, 2021

No problem. Glad you respond now.
Yes i can reproduce the deforming issue when isolating the tongue mesh.
I exported in GLB and glTF format:
https://mega.nz/folder/nNEh1SSR#uAxYtuDXfK8pqObU5yoaiQ
Hope this scene is easier to follow
Do you also need the exported .FBX file or?

Regards,

@pandaGaume
Copy link
Contributor

pandaGaume commented Jan 18, 2021

I only need the Max file, this is my starting point for debug :-), so if you can send it to me that will be nice.

@WollieWoltaz
Copy link
Author

WollieWoltaz commented Jan 18, 2021

Sure no problem:
https://mega.nz/file/bUMxUCza#lHu8VOHzdq_AXTgaAYfcE60o0UUg7ANxkNsgn_GRcXM

Not sure if you needed the Max file with or without the tongue isolation... this Max file is without
Could it be that while exporting as glTF or GLB that it's not exporting some scale transforms? Not sure though...

@pandaGaume
Copy link
Contributor

I need the file with the tongue isolation :-)

@WollieWoltaz
Copy link
Author

@pandaGaume
Copy link
Contributor

This is perfect. I will work on it this week and i will let you know if I find where this issue is located .

@WollieWoltaz
Copy link
Author

Awesome. Will wait for your reply this week.
Thanks in advance,

@WollieWoltaz
Copy link
Author

WollieWoltaz commented Jan 18, 2021

I think so yes. It's not a character i made actually so i'm not entirely sure.
I can say though that when i export this model as an FBX and import it into another tool i can see that only tongue5_SKN has his scale transform changed, it's not the default (1,1,1) anymore. I've tried setting the scale transform of that specific bone in the other tool to (1,1,1) but that didn't fixed the issue, because i think that only changing the scale transform is not enough because it also transforms to the animation keys.
Because all keys under it will be affected: poskeys, scalekeys, and rotkeys.
At least that's what I think but then again, i have no idea how to fix it in 3ds max.

@pandaGaume
Copy link
Contributor

Did you try to lower the number of Skinning Weight per vertex on the tongue (4 instead of 5)? WebGL is currently limit the number of Skinning weight per vertex to 4, and the primary intend for the exporter was for Babylon JS format and WebGL player. It evolved to export GLTF in the wait of official Max GLTF plugin. I will search in this direction. If you can make a test with 4 weight that maybe could solve your issue and save you time.

@WollieWoltaz
Copy link
Author

I have thought of that, the problem is I don't know how to do this correctly..
Could you share a little step-by-step tutorial?

@pandaGaume
Copy link
Contributor

@bghgary do you have any idea on who can help @WollieWoltaz to test fixing the number of skinning weight ?

@bghgary
Copy link
Contributor

bghgary commented Jan 19, 2021

WebGL is currently limit the number of Skinning weight per vertex to 4, and the primary intend for the exporter was for Babylon JS format and WebGL player.

Hmm, this isn't true. WebGL has no such limit. There are limits on the number of vertex attributes on various browsers/devices which may drive the limit for how many weights per vertex. Babylon.js supports up to 8 per vertex (2 sets). The glTF loader supports the same. The glTF spec itself requires that engines support at least one set (4 per vertex).

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#meshes

Client implementations must support ... one joints/weights set.

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins

The number of joints that influence one vertex is limited to 4 per set

@pandaGaume Does the exporter support more than one set of joint indices/weights?

@pandaGaume
Copy link
Contributor

8 is way better than 4... @bghgary thanks for the infos and correction. I'm currently investigate this idea, but this is the very first time i touch on this part of the code, so i may figure how it's act first, at max level, then babylon level, then gltf. Keep you posted.

@pandaGaume
Copy link
Contributor

pandaGaume commented Jan 21, 2021

OK, first test show that with 5 weight influences with a weight matrix as

Capture

the second set is not define at babylon level (into the exported babylon file)
"matricesWeightsExtra": null
for the related mesh.
I will investigate further but it's not obvious to figure where is going wrong.. :-)
Update : it seem it's not the issue while the skin define no more than 4 influences per vertex..

@pandaGaume
Copy link
Contributor

@bghgary tell the team to update https://doc.babylonjs.com/divingDeeper/mesh/bonesSkeletons where it's stated that "You should note that babylon.js supports up to 4 bones influences per vertex."

@WollieWoltaz
Copy link
Author

WollieWoltaz commented Jan 23, 2021

"it seem it's not the issue while the skin define no more than 4 influences per vertex.."
Did you find anything else then what may cause this effect?
Someone told me that glTF does not support skew or shearing, and the transform matrices must be decomposable to translation, rotation and scale.
Not sure if that's true though... just thought i should mention it here.

@pandaGaume
Copy link
Contributor

@WollieWoltaz You send us two sample where this animation failed. However the second one has strange animation rendering under max. See the attachment.
mechant.zip
could you explain what happening here at the model level ?

@pandaGaume
Copy link
Contributor

Regarding GLTF or Babylon, there is several matrices invloved.
the base formula for each join is
jointMatrix[j] = inverse(globalTransform) * globalJointTransform[j] * inverseBindMatrix[j]
Then these matrices are conbine to create the skinning matrix (which transform the vertices based on the skeleton pose before 3D rendering pipeline), so this is not obvious to figure what going wrong with the numbers :-).

@WollieWoltaz
Copy link
Author

WollieWoltaz commented Jan 24, 2021

Hmm that's strange, didn't had that issue before. How did this occur? Did you made some adjustments? If not.. then there's was probably something going wrong with the .fbx export
Here is a new .max file of the same character, with the problematic mesh isolated...
https://mega.nz/file/LFFjWKpD#GSLtjcwfaPFVxQG7u8Og92KZ4jI0ey8zJqgEtr8G2eM

@pandaGaume
Copy link
Contributor

TahmKench_attack1.zip

@bghgary
Copy link
Contributor

bghgary commented Feb 2, 2021

Using fbx2gltf, it seems to convert correctly. We can use this as reference.

TahmKench_attack1_out.zip

@WollieWoltaz
Copy link
Author

Oh that's great news..hopefully you guys figure it out. In the meanwhile...
could you give an exact example on how to use the cmd of FBX2glTF?
I haven't worked with cmd in a while, so i'm now sure what i have to type in?

Thanks,

@pandaGaume
Copy link
Contributor

pandaGaume commented Feb 2, 2021

non animated version
bestioleBabylon.zip
Animated version
animatedBestioleBabylon.zip

@bghgary
Copy link
Contributor

bghgary commented Feb 2, 2021

could you give an exact example on how to use the cmd of FBX2glTF?

fbx2gltf.exe <path to fbx>

:)

@WollieWoltaz
Copy link
Author

Got it! Thanks this is a good work-around for now :)

@thomlucc thomlucc added this to the 5.0 milestone Feb 11, 2021
@WollieWoltaz
Copy link
Author

Any new information on why this issue occurs?

@pandaGaume
Copy link
Contributor

@bghgary do we have an answer from Babylon JS team about this ?

@bghgary
Copy link
Contributor

bghgary commented Mar 10, 2021

@pandaGaume I wasn't aware you were waiting on something. Are you talking about the docs?

@pandaGaume
Copy link
Contributor

@bghgary during one of our review about this, we sent an exported scene with the bug embeded to analyse by babylon js team. It was about root transformation & skin totally wrong. My question was about this :-)

@thomlucc thomlucc added the bug label May 20, 2021
@pandaGaume pandaGaume removed the blocked label Feb 4, 2022
@thomlucc thomlucc modified the milestones: 6.0, Future Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants