bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Support FBX file loading

Open tbillington opened this issue 1 year ago • 7 comments

What problem does this solve or what need does it fill?

FBX is a commonly used file format for 3d models. Many 3d models & asset packs from asset stores, eg the popular Unity AssetStore, only supply models & materials in .fbx format.

By not supporting FBX, Bevy users must convert assets manually which is especially painful as some asset packs can have hundreds of model files. This hinders teams trying to leverage commercial assets to speed up their development.

What solution would you like?

Support FBX file import through a loader/processor.

A loader like bevy_mod_fbx could be upstreamed.

Alternatively, like Godot, leverage fbx2gltf or ufbx(current Godot default) within the engine to perform the conversion seamlessly for users

What alternative(s) have you considered?

Relying on 3rd party crates (none seem up to date), or manually converting via Blender.

Add fbx -> gltf conversion into the bevy cli tool.

Additional context

I searched for "fbx" issues previously, but couldn't find one in the repo. I assume this has been thought of before, but I wanted to formalise it.

tbillington avatar Oct 07 '24 16:10 tbillington

Great idea centralizing discussion on additional 3d model formats. I think it makes sense to have a clear path for how to do this in bevy, and for efforts to be consolidated.

I guess conversion to gltf is the discussion here, deep conversionless integration would add quite a bit of complexity both in implementation and maintenance.

Seeing as godot has picked up the reigns of FBX2glTF, us not having our own one might be more of a 'feature than a bug', as in being able to share maintenance of engine agnostic tools allows both communities to focus on other things.

Regarding batch conversion I'd personally prefer to use a cli with a simple recursive script instead of something deeply integrated and automatic, particularly because the process is lossy, but of course thats easy to say for people who write scripts and use cli tools every day.

I suppose the exact workflow for non-technical people might be easier to visualize once we have an editor, like some kind of extension that runs FBX2glTF whenever an FBX file is dragged and dropped into the asset section.

mrchantey avatar Oct 10 '24 00:10 mrchantey

I guess conversion to gltf is the discussion here

Yes. Bevy seems quite gltf-centric so converting to gltf is probably the most feasible option that also avoids increasing the logic in bevy "core".

I suppose the exact workflow for non-technical people might be easier to visualize once we have an editor, like some kind of extension that runs FBX2glTF whenever an FBX file is dragged and dropped into the asset section.

This is what Godot does, and is likely like the most user friendly solution, especially if you include teams with people who may not be CLI fluent. In my opinion, the original file should still be kept in assets, but the resulting gltf would end up in the directory from asset_processor.

tbillington avatar Oct 10 '24 07:10 tbillington

Seeing as godot has picked up the reigns of FBX2glTF

Godot 4.3 introduced a native FBX importer, ufbx, and enabled it by default. This change is more user-friendly and greatly improves the overall experience.

Since glTF and FBX are inherently different formats, direct conversion often results in information inconsistencies and other undesirable outcomes. The best solution for FBX support is to implement a native importer. Upstreaming bevy_mod_fbx is a positive step.

VitalyAnkh avatar Oct 12 '24 06:10 VitalyAnkh

@VitalyAnkh I agree that native support would be the best version of support. But my thoughts are that the fbx -> gltf route is much more palatable for the Bevy project at this point in time.

bevy_mod_fbx does a great job, but the underlying library fbxcel-dom/fbxcell is only maintained by one person, and together with bevy_mod_fbx there is quite a lot of work left to be done before it's anywhere close to Bevy's gltf support.

Unimplemented features & limitations of `bevy_mod_fbx`

Planned features

Skeleton rig imports
bevy_animation support
Optional lambert material shader support
Optional phong shading model support
Extended compatibility:
    IndexToDirect
    Handle file-based axis properties
    Handle backed cameras & lights
    N-gon triangulation

Limitations

FBX v7.4 & 7.5 are the only supported versions
FBX doesn't support multiple scenes in single file, use multiple files instead
There are no plans for loading ASCII format, export FBX as binary v7.4/7.5
There is no support for complex shapes at the moment, see https://github.com/HeavyRain266/bevy_mod_fbx/issues/11

So without someone or a group to commit to improving the situation with bevy_mod_fbx, it doesn't appear the right choice at this point in time, in my opinion.

tbillington avatar Oct 13 '24 22:10 tbillington

I'm currently working on a parser for FBX/GLB/OBJ/PLY here, what features would be necessary to incorporate it into bevy?

Edit: It doesn't have much material support yet, as I've not personally needed it. It also shares a lot of limitations of bevy_mod_fbx, but does allow for skeletal rig imports.

limitations from above:

no shading support
Extended compatibility:
    Handle file-based axis properties (Not sure what this means, if it's global or not)
    Handle backed cameras & lights
    N-gon triangulation (Computing a triangle fan is fine, but doesn't have ear clipping)

Currently export is very limited, and there is no support for ascii import (but ascii files are rare in practice?)

I realize there is likely a large gap between what is currently supported and what is needed, but knowing what is needed will help me figure out which features I should focus on.

JulianKnodt avatar Mar 27 '25 03:03 JulianKnodt

Seems like Blender contributors are prototyping integrating ufbx too. Issue and PR.

I just saw that ufbx is a single source file C99/C++11 library, so it's possible generating Rust bindings might not be that difficult.

tbillington avatar Mar 28 '25 03:03 tbillington

Is anyone working on generating Rust bindings?

FizzWizZleDazzle avatar Jun 03 '25 11:06 FizzWizZleDazzle

ufbx has an official rust binding: https://github.com/ufbx/ufbx-rust.

VitalyAnkh avatar Jun 06 '25 07:06 VitalyAnkh

Yeah I just saw that.

FizzWizZleDazzle avatar Jun 06 '25 15:06 FizzWizZleDazzle

I have submitted a PR to add FBX loader based on ufbx: https://github.com/bevyengine/bevy/pull/19534.

VitalyAnkh avatar Jun 08 '25 15:06 VitalyAnkh

It seems FBX is going to be deprecated and tools moving to OpenUSD/GLTF https://www.youtube.com/watch?v=_quZ1QRysSU&t=1379s

Igor-dvr avatar Aug 31 '25 09:08 Igor-dvr

It seems FBX is going to be deprecated and tools moving to OpenUSD/GLTF https://www.youtube.com/watch?v=_quZ1QRysSU&t=1379s

Even if FBX gets deprecated, there’s still a huge amount of existing assets and pipelines built around it. Many libraries/marketplaces still distribute FBX, and it often carries data like rigs, animation curves, and material setups that aren’t always preserved in glTF/USD.

FizzWizZleDazzle avatar Aug 31 '25 16:08 FizzWizZleDazzle

and it often carries data like rigs, animation curves, and material setups that aren’t always preserved in glTF/USD.

It seems there are also plans to implement FBX features in GLTF/USD.

Image

Igor-dvr avatar Aug 31 '25 17:08 Igor-dvr

And I'm not against this. Just shared the info. FBX/OpenUSD curve support would be nice. Gltf doesn't support curves.

Igor-dvr avatar Aug 31 '25 21:08 Igor-dvr

A Bevy plugin for loading FBX files using the ufbx library

https://github.com/FizzWizZleDazzle/bevy_ufbx

Igor-dvr avatar Sep 24 '25 13:09 Igor-dvr