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

Models deforming when converting from Blender to GLTF #2104

Open
cgordon5025 opened this issue Jan 9, 2024 · 18 comments
Open

Models deforming when converting from Blender to GLTF #2104

cgordon5025 opened this issue Jan 9, 2024 · 18 comments
Labels
Blender bug Something isn't working discussion

Comments

@cgordon5025
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to File>Export>GLTF
  2. Click on ExportToGLTF
  3. See error

Expected behavior
When exporting my scene with animated models, I expect that the models retain their structure and integrity as I see it in the blender GUI.

Screenshots
Expected Behavior (screenshot taken in Blender):
Screenshot 2024-01-08 182344

Actual Behavior (screenshot taken in React Project):
Screenshot 2024-01-08 182316

myProject.zip

Version

  • OS: Windows 11 Build 22621.2861
  • Blender Version: 3.4.1 Date 2022-12-19

Additional context
Add any other context about the problem here.
I am using the polmandres GLTF to JSX converter to render this, when using their provided GLTF viewer (https://gltf.pmnd.rs/) the models looks correct, yet in the project they are warped. Further when I export within Blender, I see immediately that the Fox and Dog models have the same deformation that appear in the gltf file. If I click undo, they are 'fixed', but the gltf remains warped.

@donmccurdy
Copy link
Contributor

To help us narrow this down, do you see the same issue when running gltfjsx with a higher precision? The default is 3 decimals precision in node position/rotation/scale, which could be an issue. There's an option for this in the gltfjsx GUI, or the --precision flag in the CLI. I think the CLI is generally more up-to-date than the web GUI.

Further when I export within Blender, I see immediately that the Fox and Dog models have the same deformation that appear in the gltf file...

I'm not sure I understood this part, do you mean you see the deformation in Blender after export, unrelated to gltfjsx? I'm testing in Blender 4.0 and not seeing the deformation there so far.

@julienduroure
Copy link
Collaborator

Seems your rigs are using BBone, that can not be exported in glTF.
This can explain deformation issue in any glTF viewer.

Note that Blender now have the requested API to convert BBone to multiple bones. But the work still to be done to manage it correctly at export is huge, and not planned for now.

@cgordon5025
Copy link
Author

cgordon5025 commented Jan 10, 2024

I'm not sure I understood this part, do you mean you see the deformation in Blender after export, unrelated to gltfjsx? I'm testing in Blender 4.0 and not seeing the deformation there so far.
@donmccurdy

Thought I had resolved it by updating my blender to 4.0, things were working yesterday and now this morning it broke once again. Yes, both the gltf file and Blender have deformed bones after the export occurs. This morning I had to make a quick adjustment to the scene, and when I exported it once more the bones deformed again

@cgordon5025
Copy link
Author

cgordon5025 commented Jan 10, 2024

Seems your rigs are using BBone, that can not be exported in glTF. This can explain deformation issue in any glTF viewer.

Note that Blender now have the requested API to convert BBone to multiple bones. But the work still to be done to manage it correctly at export is huge, and not planned for now.
@julienduroure
I used rigify to create the rig. I am fairly new to Blender. Is there any way I can remove/change this without restarting the rig? Or a way to convert it myself before exporting?

@cgordon5025
Copy link
Author

@julienduroure Another question, if it is the bendy bones why are the two other rigged models in this file work/retain their structure, while the two quadrupeds lose it?

@julienduroure
Copy link
Collaborator

If you want me to investigate more deeply, can you please create a new .blend file with only the dog and a single action for it, where we can see the deformation the best, and indicate what part is deformed.

As far as I can see, there is not so much BBone deformation on owl and crab (even if there is some BBones).

But there are for the dog (on the neck for example):

image

@cgordon5025
Copy link
Author

cgordon5025 commented Jan 10, 2024

@julienduroure
Sure I can provide that. What is odd, is that I made a demo version of this file with only one animal, and it exported without problem. I have since updated to Blender 4.0, but the issue is still persisting. I am noticing it is only the front paws of both the fox and dog (quadrupeds) that are affected, would changing the bone type for that segment resolve this, though in an unorthodox manner?
DogCustomRig.zip

In the main file, where I see the deformation occur is on the front two paws on the joint just above the foot, identified as the foot_front_heel, in the model you can see its near perpendicular to the xy axis, but when I export to gltf it becomes more parallel to the xy axis.

This deformation occurs on the neutral pose of the models, so it affects every animation they use

@julienduroure
Copy link
Collaborator

Sorry, but I am not able to understand clearly what your problem is.

Is your blend file changed after export, or is the issue can be viewed in an external viewer?
Please make some screenshots that show the issue.

Is it some bone/joint rotation issue, or the problem come from geometry/mesh issue?
There is no "foot_front_heel" in your file. Do you mean "front_foot_heel_ik.R/L" ?

Does your DogCustomRig shows the issue, or only the main file myProject ?

@cgordon5025
Copy link
Author

@julienduroure my Blender file is changed after export AND the deformation is viewed in the final destination. When using a GLTF viewer (https://gltf.pmnd.rs/) the issue does not show itself.

It seems to be a bone rotation issue, that after executing the export front_foot_heel)ik.R/L changes its orientation. Because the rig is parent to the model, the model deforms due to the front_foot_heel_ik.R/L changing orientation/rotation.

CustomDogRig was showing no issues when I tried to export it. The issue is only in the main file (myProject)

Below are photos of the model in three different environments
In blender (before exporting)
inBlender

In GLTF Viewer

inGLTFViewer

In ReactProject and Blender after exporting
inReactProject

@julienduroure
Copy link
Collaborator

Seems I am not able to reproduce

Before Export :

Pose
image

Rest
image

After Export:

image

Pose
image

Rest
image

In https://gltf.pmnd.rs/

image

In https://gltf-viewer.donmccurdy.com/

image

@julienduroure julienduroure added the question Further information is requested label Jan 14, 2024
@cgordon5025
Copy link
Author

@julienduroure This is correct, however noce you convert this to jsx and using gltfjsx, you will see that the animations are all deformed. the strangest part is that the neutral poses are correct, but once you apply the animation it does not work any more.

Attached is the sandbox I have been using to test my animations in a React project

animation-sandbox.zip

@donmccurdy
Copy link
Contributor

donmccurdy commented Jan 18, 2024

@cgordon5025 is it possible to observe the deformation in any of these viewers?

If not, I think it may be necessary to report an issue at https://github.com/pmndrs/gltfjsx/. This exporter aims to produce a valid and visually-correct glTF file. Generating a JSX template from that is an additional process with its own complexities.

@cgordon5025
Copy link
Author

@donmccurdy Yes, in the first link provided, https://gltf-viewer.donmccurdy.com/

You can see that the dog, when in idle/rest position that the legs are proper and not deformed, but when activating the animation, the rig becomes deformed

See attached video.

DogRigDeformingWhileAnimating.mp4

@julienduroure
Copy link
Collaborator

The legs are also with this shape in Blender before export , when using this action DogHeadNod

image

@cgordon5025
Copy link
Author

cgordon5025 commented Jan 18, 2024

@julienduroure In my blender file they are not like that, let me send another
playground.zip

I have noticed that if it is not deformed before exporting, it will become deformed, but then you are able to undo w/ control-z

@julienduroure
Copy link
Collaborator

I can reproduce with this new .blend file
Investigation in progress

@julienduroure julienduroure added bug Something isn't working and removed question Further information is requested labels Jan 18, 2024
@julienduroure
Copy link
Collaborator

I opened a discussion here about the Blender API to reset bones to rest pose (that is root of the issue):

https://projects.blender.org/blender/blender/issues/118077

@julienduroure
Copy link
Collaborator

Some bones are locked and have non default values (MCH-front_foot_parent.L for example). During switch between actions, to avoid unexpected issue when some channels are keyed on an action, but not in another, we reset bone matrices. This reset make all matrices Identity. But because of non default locked bone, this is not the behavior we get when using Clear Transforms (alt+G/R/S).

You can workaround that (if all your channels are keyed) by disable this option: Reset Bones between actions

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blender bug Something isn't working discussion
Projects
None yet
Development

No branches or pull requests

3 participants