-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add ufbx for FBX importing #81746
Add ufbx for FBX importing #81746
Conversation
By the way, ufbx also has optional support for importing Wavefront |
@bqqbarbhg It's a good idea, but I would prefer to merge ufbx for FBX importing first and then we can expose the obj importer later. For clarity and maintenance ease. |
The codebase is synced from https://github.com/V-Sekai/godot-ufbx and has commit logs. |
Tested with so far no issues, good work 👍 |
From @bqqbarbhg the latest update supports fixes bone scaling when using unusual inherit modes.
|
This comment was marked as outdated.
This comment was marked as outdated.
8b0e914
to
be02fa7
Compare
Needed to rebase because of https://github.com/godotengine/godot/pull/81968/files preventing me from testing mac. |
TL;DR we bias the importer towards Maya FBX because it is the pipeline lacking representation in Godot Engine, Blender has a functional GLTF pipeline and if needed Blender has a workaround using the FBX exporter option "FBX Units Scale". In-depth summaryHere's an ai summary of our conversation [iFire, and bqqbarbhg] why to bias Maya FBX vs Blender FBX: In the context of the godot-ufbx, we bias towards Maya FBX files over Blender FBX files by using The When you use If you are exporting your models from Blender, you can select the "FBX Units Scale" option before exporting. This will ensure that the scale factor is correctly set during export, avoiding the need for manual adjustment when importing back into Blender. blender_default.fbx ExampleExport the test scene from Blender will save the file as:
importing with UFBX_SPACE_CONVERSION_ADJUST_TRANSFORMS modifies it to
and UFBX_SPACE_CONVERSION_MODIFY_GEOMETRY modifies it to
and on the other hand exporting a triangle like that from Maya would usually be like
|
I talked with @bqqbarbhg about it being good to have camera/light support back in and updating ufbx fixes to include. My plan is to prepare for merge first and try get additional updates for camera/light and the ufbx library later. Our discussion mentioned that threading will help with performance but ufbx is far from the biggest bottleneck and have some ufbx fixes from fuzzing. |
if (p_options.has("fbx/importer") && int(p_options["fbx/importer"]) == FBX_IMPORTER_FBX2GLTF) { | ||
Ref<EditorSceneFormatImporterFBX> fbx2gltf_importer; | ||
// FIXME: Hack to work around GH-86309. | ||
if (p_options.has("fbx/importer") && int(p_options["fbx/importer"]) == FBX_IMPORTER_FBX2GLTF && GLOBAL_GET("filesystem/import/fbx2gltf/enabled")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check for whether the fbx2gltf importer is actually enabled. Needs testing.
da1f04c
to
0ffb10d
Compare
@lyuma discussed with me removing the Thoughts? |
Yeah I think it's the way to go if it's not doable to have a gltf/fbx agnostic abstraction 👍 Edit: I'm fine with merging this PR as is, and seeing the architecture refactored further in a follow-up PR. |
More commentary:
Edited: Extract common code like methods that don't depend on the internal state of the fbx or gltf documents. |
@@ -1168,7 +1168,7 @@ bool ProjectConverter3To4::test_array_names() { | |||
|
|||
// Callable is special class, to which normal classes may be renamed. | |||
if (!ClassDB::class_exists(StringName(new_class)) && new_class != "Callable") { | |||
ERR_PRINT(vformat("Class \"%s\" does not exist in Godot 4, so it cannot be used in the conversion.", old_class)); | |||
ERR_PRINT(vformat("Class \"%s\" does not exist in Godot 4, so it cannot be used in the conversion.", new_class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to this PR, but I triggered that bug while renaming EditorSceneFormatImporterFBX
to EditorSceneFormatImporterFBX2GLTF
, so I figured I'd fix it too.
We've been testing using the fbx: https://sketchfab.com/3d-models/shibahu-2e9dffd948f747668609a5a477daad86. This Shibahu model is fairly complicated and has blend shape animations which broke previously. I'll compile and test. godot_engine_fbx_shibahu_d223e45e6e2d0067183529ef8dffd4f853c11b60.movOn d223e45 with shibahu Seems to work, the materials are expected not importing, so we're testing in normals debug mode. |
Updated to fix merge conflict in |
This update introduces a new import method for FBX files using ufbx. If the fbx2gltf import fails, it will use the most recently cached scene from the ufbx import. The process is sped up by introducing threads to load the ufbx portion. Key changes include: - Support for importing geometry helper nodes in FBX files. - Addition of cameras and lights with updated names. - Removal of the fbx importer manager. - Introduction of ModelDocument3D and updates to its methods. - Changes to FBX import options and visibility. - Updating the documentation and handling some errors. - Store the original non-unique node, mesh and animation names in FBX and glTF. Co-Authored-By: bqqbarbhg <bqqbarbhg@gmail.com>
Updated with the changes from #88680, and squashed all commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good to merge now.
We finally settled down on an architecture where the fbx module extends and depends on the gltf module, reusing what it can.
Thanks! Amazing work @fire and @bqqbarbhg! |
Yes indeed! Thanks both of you for your great job.
Maybe I don't understand something, but in the face of it, it will make it possible to test that a FBX document is a GLTF document. This seems wrong. Maybe it's super difficult to implement an agnostic abstraction, but it still seems wrong. |
This restores FBX imports in Godot.
I would need people to test their models, or downloaded models. Specifically, I want to test that:
To test this properly, a variety of models is required, so do not hesitate to try different ones. You can find free FBX models at https://sketchfab.com/3d-models?features=downloadable (be careful, you may see NSFW models).
If you run into an issue, please post here with your OS, and as much information as you can about the error.
Screen_Recording_2023-09-15_at_2.49.16_PM.mov
This work is supported as part of V-Sekai and with help from @bqqbarbhg.
The work was approved at the Animation / 3D Pipeline meeting and was also discussed with the production team as an experimental marked feature for 4.3.
No proposal exists because this restores FBX import with around five to eight repeated attempts.
See also https://github.com/V-Sekai/godot-ufbxFinalization after 4.3 window is open
- [ ] Fix engine bugs on 2 gigabyte fbx samples (cc-by)Finalization before 4.3 window closes
Curve pathsKnown Issues
When the fbx2gltf import has failed it will use the mostly recently cached scene from the ufbx import.
See #86309 for the related issue.
Production edit: closes godotengine/godot-roadmap#40