• Stars
    star
    1,963
  • Rank 22,633 (Top 0.5 %)
  • Language
    C++
  • License
    Other
  • Created over 6 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A command-line tool for the conversion of 3D model assets on the FBX file format to the glTF file format.

FBX2glTF

License

This is a command line tool for converting 3D model assets on Autodesk's venerable FBX format to glTF 2.0, a modern runtime asset delivery format.

Precompiled binaries releases for Windows, Mac OS X and Linux may be found here.

Bleeding-edge binaries for Windows may be found here. Linux and Mac OS X to come; meanwhile, you can build your own.

Build Status Build status

Running

The tool can be invoked like so:

 > FBX2glTF ~/models/butterfly.fbx

Or perhaps, as part of a more complex pipeline:

 > FBX2glTF --binary --draco --verbose \
          --input ~/models/source/butterfly.fbx \
          --output ~/models/target/butterfly.glb

There are also some friendly & hands-on instructions available over at Facebook.

CLI Switches

You can always run the binary with --help to see what options it takes:

FBX2glTF 0.9.7: Generate a glTF 2.0 representation of an FBX model.
Usage: FBX2glTF [OPTIONS] [FBX Model]

Positionals:
  FBX Model FILE              The FBX model to convert.

Options:
  -h,--help                   Print this help message and exit
  -v,--verbose                Include blend shape tangents, if reported present by the FBX SDK.
  -V,--version
  -i,--input FILE             The FBX model to convert.
  -o,--output TEXT            Where to generate the output, without suffix.
  -e,--embed                  Inline buffers as data:// URIs within generated non-binary glTF.
  -b,--binary                 Output a single binary format .glb file.
  --long-indices (never|auto|always)
                              Whether to use 32-bit indices.
  --compute-normals (never|broken|missing|always)
                              When to compute vertex normals from mesh geometry.
  --anim-framerate (bake24|bake30|bake60)
                              Select baked animation framerate.
  --flip-u                    Flip all U texture coordinates.
  --no-flip-u                 Don't flip U texture coordinates.
  --flip-v                    Flip all V texture coordinates.
  --no-flip-v                 Don't flip V texture coordinates.
  --no-khr-lights-punctual    Don't use KHR_lights_punctual extension to export FBX lights.
  --user-properties           Transcribe FBX User Properties into glTF node and material 'extras'.
  --blend-shape-normals       Include blend shape normals, if reported present by the FBX SDK.
  --blend-shape-tangents      Include blend shape tangents, if reported present by the FBX SDK.
  -k,--keep-attribute (position|normal|tangent|binormial|color|uv0|uv1|auto) ...
                              Used repeatedly to build a limiting set of vertex attributes to keep.
  --fbx-temp-dir DIR          Temporary directory to be used by FBX SDK.


Materials:
  --pbr-metallic-roughness    Try to glean glTF 2.0 native PBR attributes from the FBX.
  --khr-materials-unlit       Use KHR_materials_unlit extension to request an unlit shader.


Draco:
  -d,--draco                  Apply Draco mesh compression to geometries.
  --draco-compression-level INT in [0 - 10]=7
                              The compression level to tune Draco to.
  --draco-bits-for-position INT in [1 - 32]=14
                              How many bits to quantize position to.
  --draco-bits-for-uv INT in [1 - 32]=10
                              How many bits to quantize UV coordinates to.
  --draco-bits-for-normals INT in [1 - 32]=10
                              How many bits to quantize nornals to.
  --draco-bits-for-colors INT in [1 - 32]=8
                              How many bits to quantize colors to.
  --draco-bits-for-other INT in [1 - 32]=8
                              How many bits to quantize all other vertex attributes to.

Some of these switches are not obvious:

  • --embed is the way to get a single distributable file without using the binary format. It encodes the binary buffer(s) as a single base64-encoded data:// URI. This is a very slow and space-consuming way to accomplish what the binary format was invented to do simply and efficiently, but it can be useful e.g. for loaders that don't understand the .glb format.
  • --flip-u and --flip-v, when enabled, will apply a x -> (1.0 - x) function to all u or v texture coordinates respectively. The u version is perhaps not commonly used, but flipping v is the default behaviour. Your FBX is likely constructed with the assumption that (0, 0) is bottom left, whereas glTF has (0, 0) as top left. To produce spec-compliant glTF, we must flip the texcoords. To request unflipped coordinates:
  • --long-indices lets you force the use of either 16-bit or 32-bit indices. The default option is auto, which make the choice on a per-mesh-size basis.
  • --compute-normals controls when automatic vertex normals should be computed from the mesh. By default, empty normals (which are forbidden by glTF) are replaced. A choice of 'missing' implies 'broken', but additionally creates normals for models that lack them completely.
  • --no-flip-v will actively disable v coordinat flipping. This can be useful if your textures are pre-flipped, or if for some other reason you were already in a glTF-centric texture coordinate system.
  • All three material options are, in their own way, works in progress, but the --pbr-metallic-roughness switch is at least compliant with the core spec; unlike the others, it does not depend on an unratified extension. That option will be chosen by default if you supply none of the others. Material switches are documented further below.
  • If you supply any -keep-attribute option, you enable a mode wherein you must supply it repeatedly to list all the vertex attributes you wish to keep in the conversion process. This is a way to trim the size of the resulting glTF if you know the FBX contains superfluous attributes. The supported arguments are position, normal, tangent, color, uv0, and uv1.
  • When blend shapes are present, you may use --blend-shape-normals and --blend-shape-tangents to include normal and tangent attributes in the glTF morph targets. They are not included by default because they rarely or never seem to be correctly present in the actual FBX source, which means the SDK must be computing them from geometry, unasked? In any case, they are beyond the control of the artist, and can yield strange crinkly behaviour. Since they also take up significant space in the output file, we made them opt-in.

Building it on your own

We currently depend on the open source projects Draco, MathFu, Json, cppcodec, CLI11, stb, and fmt; all of which are automatically downloaded and/or built.

At present, only version 2019.2 of the FBX SDK is supported. The build system will not successfully locate any other version.

Linux and MacOS X

Your development environment will need to have:

  • build essentials (gcc for Linux, clang for Mac)
  • cmake
  • python 3.* and associated pip3/pip command
  • zstd

Then, compilation on Unix machines will look something like:

# Determine SDK location & build settings for Linux vs (Recent) Mac OS X
> if [[ "$OSTYPE" == "darwin"* ]]; then
    export CONAN_CONFIG="-s compiler=apple-clang -s compiler.version=10.0 -s compiler.libcxx=libc++"
    export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Darwin/archive/2019.2.tar.gz"
elif [[ "$OSTYPE" == "linux"* ]]; then
    export CONAN_CONFIG="-s compiler.libcxx=libstdc++11"
    export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Linux/archive/2019.2.tar.gz"
else
    echo "This snippet only handles Mac OS X and Linux."
fi

# Fetch Project
> git clone https://github.com/facebookincubator/FBX2glTF.git
> cd FBX2glTF

# Fetch and unpack FBX SDK
> curl -sL "${FBXSDK_TARBALL}" | tar xz --strip-components=1 --include */sdk/
# Then decompress the contents
> zstd -d -r --rm sdk

# Install and configure Conan, if needed
> pip3 install conan # or sometimes just "pip"; you may need to install Python/PIP
> conan remote add --force bincrafters https://api.bintray.com/conan/bincrafters/public-conan

# Initialize & run build
> conan install . -i build -s build_type=Release ${CONAN_CONFIG}
> conan build . -bf build

If all goes well, you will end up with a statically linked executable in ./build/FBX2glTF.

Windows

the below is out of date

Windows users may download CMake for Windows, install it and run it on the FBX2glTF checkout (choose a build directory distinct from the source).

As part of this process, you will be asked to choose which generator to use. At present, only Visual Studio 2017 or 2019 is supported. Older versions of the IDE are unlikely to successfully build the tool.

Note that the CMAKE_BUILD_TYPE variable from the Unix Makefile system is entirely ignored here; it is when you open the generated solution that you will be choose one of the canonical build types โ€” Debug, Release, MinSizeRel, and so on.

Conversion Process

The actual translation begins with the FBX SDK parsing the input file, and ends with the generation of the descriptive JSON that forms the core of glTF, along with binary buffers that hold geometry and animations (and optionally also emedded resources such as textures.)

In the process, each mesh is ripped apart into a long list of triangles and their associated vertices, with a material assigned to each one. A similar process happens in reverse when we construct meshes and materials that conform to the expectations of the glTF format.

Animations

Every animation in the FBX file becomes an animation in the glTF file. The method used is one of "baking": we step through the interval of time spanned by the animation, keyframe by keyframe, calculate the local transform of each node, and whenever we find any node that's rotated, translated or scaled, we record that fact in the output.

Beyond skeleton-based animation, Blend Shapes are also supported; they are read from the FBX file on a per-mesh basis, and clips can use them by varying the weights associated with each one.

The baking method has the benefit of being simple and precise. It has the drawback of creating potentially very large files. The more complex the animation rig, the less avoidable this data explosion is.

There are three future enhancements we hope to see for animations:

  • Version 2.0 of glTF brought us support for expressing quadratic animation curves, where previously we had only had linear. Not coincidentally, quadratic splines are one of the key ways animations are expressed inside the FBX. When we find such a curve, it would be more efficient to output it without baking it into a long sequence of linear approximations.
  • We do not yet ever generate sparse accessors, but many animations (especially morph targets) would benefit from this storage optimisation.
  • Perhaps most useful in practice is the idea of compressing animation curves the same way we use Draco to compress meshes (see below). Like geometry, animations are highly redundant โ€” each new value is highly predictable from preceding values. If Draco extends its support for animations (it's on their roadmap), or if someone else develops a glTF extension for animation compression, we will likely add support in this tool.

Materials

With glTF 2.0, we leaped headlong into physically-based rendering (PBR), where the canonical way of expressing what a mesh looks like is by describing its visible material in fundamental attributes like "how rough is this surface".

By contrast, FBX's material support remains largely in the older world of Lambert and Phong, with simpler and more direct illumination and shading models. These modes are inherently incompatible โ€” for example, textures in the old workflow often contain baked lighting of the type that would arise naturally in a PBR environment.

Some material settings remain well supported and transfer automatically:

  • Emissive constants and textures
  • Occlusion maps
  • Normal maps

This leaves the other traditional settings, first of Lambert:

  • Ambient โ€” this is anathema in the PBR world, where such effects should emerge naturally from the fundamental colour of the material and any ambient lighting present.
  • Diffuse โ€” the material's direction-agnostic, non-specular reflection, and additionally, with Blinn/Phong:
  • Specular โ€” a more polished material's direction-sensitive reflection,
  • Shininess โ€” just how polished the material is; a higher value here yields a more mirror-like surface.

(All these can be either constants or textures.)

Exporting as Unlit

If you have a model was constructed using an unlit workflow, e.g. a photogrammetry capture or a landscape with careful baked-in lighting, you may choose to export it using the --khr-materials-common switch. This incurs a dependency on the glTF extension 'KHR_materials_unlit; a client that accepts that extension is making a promise it'll do its best to render pixel values without lighting calculations.

Note that at the time of writing, this glTF extension is still undergoing the ratification process

Exporting as Metallic-Roughness PBR

Given the command line flag --pbr-metallic-roughness, we throw ourselves into the warm embrace of glTF 2.0's PBR preference.

As mentioned above, there is little consensus in the world on how PBR should be represented in FBX. At present, we support only one format: Stingray PBS. This is a feature that comes bundled with Maya, and any PBR model exported through that route should be digested propertly by FBX2glTF.

(A happy note: Allegorithmic's Substance Painter also exports Stingray PBS, when hooked up to Maya.)

Draco Compression

The tool will optionally apply Draco compression to the geometric data of each mesh (vertex indices, positions, normals, per-vertex color, and so on). This can be dramatically effective in reducing the size of the output file, especially for static models.

Enabling this feature adds an expressed required dependency in the glTF on the KHR_draco_geometry_compression extension, and can thus only be loaded by a viewer that is willing and able to decompress the data.

Note that at the time of writing, this glTF extension is still undergoing the ratification process.

Future Improvements

This tool is under continuous development. We do not have a development roadmap per se, but some aspirations have been noted above. The canonical list of active TODO items can be found on GitHub.

Authors

  • Pรคr Winzell
  • J.M.P. van Waveren
  • Amanda Watson

License

FBX2glTF is licensed under the 3-clause BSD license.

More Repositories

1

SocketRocket

A conforming Objective-C WebSocket client library.
Objective-C
9,524
star
2

katran

A high performance layer 4 load balancer
C
4,488
star
3

AITemplate

AITemplate is a Python framework which renders neural network into high performance CUDA/HIP C++ code. Specialized for FP16 TensorCore (NVIDIA GPU) and MatrixCore (AMD GPU) inference.
Python
4,418
star
4

cinder

Cinder is Meta's internal performance-oriented production version of CPython.
Python
3,349
star
5

velox

A C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.
C++
3,138
star
6

spectrum

A client-side image transcoding library.
C++
1,985
star
7

oomd

A userspace out-of-memory killer
C++
1,745
star
8

xar

executable archive format
Python
1,578
star
9

fastmod

A fast partial replacement for the codemod tool
Rust
1,570
star
10

Bowler

Safe code refactoring for modern Python.
Python
1,506
star
11

gloo

Collective communications library with various primitives for multi-machine training.
C++
1,128
star
12

fizz

C++14 implementation of the TLS-1.3 standard
C++
1,104
star
13

submitit

Python 3.8+ toolbox for submitting jobs to Slurm
Python
1,075
star
14

dhcplb

dhcplb is Facebook's implementation of a load balancer for DHCP.
Go
1,035
star
15

below

A time traveling resource monitor for modern Linux systems
Rust
975
star
16

OnlineSchemaChange

A tool for performing online schema changes on MySQL.
Python
951
star
17

Glean

System for collecting, deriving and working with facts about source code.
Hack
886
star
18

Battery-Metrics

Library that helps in instrumenting battery related system metrics.
Java
720
star
19

retrie

Retrie is a powerful, easy-to-use codemodding tool for Haskell.
Haskell
490
star
20

superconsole

The superconsole crate provides a handler and building blocks for powerful, yet minimally intrusive TUIs. It is cross platform, supporting Windows 7+, Linux, and MacOS. Rustaceans who want to create non-interactive TUIs can use the component composition building block system to quickly deploy their code.
Rust
447
star
21

nvdtools

A set of tools to work with the feeds (vulnerabilities, CPE dictionary etc.) distributed by National Vulnerability Database (NVD)
Go
428
star
22

infima

A UI framework that provides websites with the minimal CSS and JS needed to get started with building a modern responsive beautiful website
HTML
393
star
23

CG-SQL

CG/SQL is a compiler that converts a SQL Stored Procedure like language into C for SQLite. SQLite has no stored procedures of its own. CG/CQL can also generate other useful artifacts for testing and schema maintenance.
HTML
385
star
24

flowtorch

This library would form a permanent home for reusable components for deep probabilistic programming. The library would form and harness a community of users and contributors by focusing initially on complete infra and documentation for how to use and create components.
Jupyter Notebook
297
star
25

ptr

Python Test Runner.
Python
285
star
26

TTPForge

The TTPForge is a Cybersecurity Framework for developing, automating, and executing attacker Tactics, Techniques, and Procedures (TTPs).
Go
280
star
27

fbjni

A library designed to simplify the usage of the Java Native Interface
C++
245
star
28

senpai

Senpai is an automated memory sizing tool for container applications.
Python
213
star
29

gazebo

A Rust library containing a collection of small well-tested primitives.
Rust
210
star
30

dynolog

Dynolog is a telemetry daemon for performance monitoring and tracing. It exports metrics from different components in the system like the linux kernel, CPU, disks, Intel PT, GPUs etc. Dynolog also integrates with pytorch and can trigger traces for distributed training applications.
C++
161
star
31

reindeer

Reindeer is a tool to transform Rust Cargo dependencies into generated Buck build rules
Rust
157
star
32

FCR

FBNet-Command-Runner: A thrift service to run commands on heterogeneous Network devices with configurable parameters.
Python
154
star
33

GeoLift

GeoLift is an end-to-end geo-experimental methodology based on Synthetic Control Methods used to measure the true incremental effect (Lift) of ad campaign.
R
149
star
34

oculus-linux-kernel

The Linux kernel code for Oculus devices
C
148
star
35

hsthrift

The Haskell Thrift Compiler. This is an implementation of the Thrift spec that generates code in Haskell. It depends on the fbthrift project for the implementation of the underlying transport.
Haskell
143
star
36

dispenso

The project provides high-performance concurrency, enabling highly parallel computation.
C++
141
star
37

FioSynth

Tool which enables the creation of synthetic storage workloads, automates the execution and results collection of synthetic storage benchmarks.
Python
136
star
38

dataclassgenerate

DataClassGenerate (or simply DCG) is a Kotlin compiler plugin that addresses an Android APK size overhead from Kotlin data classes.
Kotlin
134
star
39

meta-code-verify

Code Verify is an open source web browser extension that confirms that your Facebook, Messenger, Instagram, and WhatsApp Web code hasnโ€™t been tampered with or altered, and that the Web experience youโ€™re getting is the same as everyone elseโ€™s.
TypeScript
133
star
40

go-qfext

a fast counting quotient filter implementation in golang
Go
88
star
41

tacquito

Tacquito is an open source TACACs+ server written in Go that implements RFC8907
Go
82
star
42

dcrpm

A tool to detect and correct common issues around RPM database corruption.
Python
72
star
43

ForgeArmory

ForgeArmory provides TTPs that can be used with the TTPForge (https://github.com/facebookincubator/ttpforge).
Swift
67
star
44

antlir

ANother Linux Image buildeR
Rust
63
star
45

ConversionsAPI-Tag-for-GoogleTagManager

This repository will contain the artifacts needed for setting up Conversions API implementation on Google Tag Manager's serverside. Please follow the instructions https://www.facebook.com/business/help/702509907046774
Smarty
63
star
46

InjKit

Injection Kit. It is a java bytecode processing library for bytecode injection and transformation.
Java
56
star
47

sks

Secure Key Storage (SKS) is a library for Go that abstracts Security Hardware on laptops.
Go
55
star
48

obs-plugins

OBS Plugins
C++
54
star
49

glTFVariantMeld

An application that accepts files on the glTF format, interprets them as variants of an over-arching whole, and melds them together.
Rust
47
star
50

later

A framework for python asyncio with batteries included for people writing services in python asyncio
Python
38
star
51

go2chef

A Golang tool to bootstrap a system from zero so that it's able to run Chef to be managed
Go
38
star
52

ConversionsAPI-Client-for-GoogleTagManager

This repository will contain the artifacts needed for setting up Conversions API implementation on Google Tag Manager's serverside. Primarily we will be hosting, - ConversionsAPI(Facebook) Client - listens on the events fired to GTM Server and maps them to common GTM schema. - ConversionsAPI(Facebook) Tag - server tag that fires events to CAPI.For more details on Design here https//fburl.com/uae68vlr
37
star
53

CommutingZones

Commuting zones are geographic areas where people live and work and are useful for understanding local economies, as well as how they differ from traditional boundaries. These zones are a set of boundary shapes built using aggregated estimates of home and work locations. Data used to build commuting zones is aggregated and de-identified.
JavaScript
37
star
54

Facebook-Pixel-for-Wordpress

A plugin for advertisers who use Wordpress to enable them easily setup the facebook pixel.
JavaScript
34
star
55

wordpress-messenger-customer-chat-plugin

Messenger Customer Chat Plugin for WordPress
PHP
26
star
56

CP4M

CP4M is a conversational marketing platform which enables advertisers to integrate their customer-facing chatbots with FB Messenger/WhatsApp, in order to meet customers where they are and drive native conversations on the advertiser's owned infra.
Java
26
star
57

rush

RUSH (Reliable - unreliable - Streaming Protocol)
C++
22
star
58

buck2-change-detector

Given a Buck2 built project and a set of changes (e.g. from source control) compute the targets that may have changed. Sometimes known as a target determinator, useful for optimizing a CI system.
Rust
18
star
59

MY_ENUM

Small c++ macro library to add compile-time introspection to c++ enum classes.
C++
15
star
60

spark-ar-core-libs

Core libraries that can be used in Spark AR. You can import each library depends on your requirements.
TypeScript
15
star
61

SafeC

Library containing safer alternatives/wrappers for insecure C APIs.
C++
14
star
62

go-belt

It is an implementation-agnostic Go(lang) package to generalize observability tooling (logger, metrics, tracer and so on) and provide ability to use any of these tools with a standard context. Essentially it is an attempt to standardize observability API in Go.
Go
14
star
63

Portal-Kernel

Kernel Code for Portal.
C
11
star
64

sado

A macOS signed-app shim for running daemons with reliable capabilities.
Swift
10
star
65

npe-toolkit

Libraries, guides, blueprints, and sample code, to enable rapidly building 0-1 applications on iOS, Android and web.
TypeScript
9
star
66

Eigen-FBPlugins

This is collection of plugins extending Eigen arrays/matrices with main focus on using them for computer vision. In particular, this project should provide support for multichannel arrays (missing in vanilla Eigen) and seamless integration between Eigen types and OpenCV functions.
C++
8
star
67

isometric_pattern_matcher

A new isometric calibration pattern - which should/might lead to higher accuracy calibrations compared to existing solutions (checkerboards, patterns of circles).
C++
8
star
68

dnf-plugin-cow

Code to enable Copy on Write features being upstreamed in rpm and librepo
Shell
8
star
69

wireguard_py

Cython library for Wireguard
C
6
star
70

strobelight

Meta's fleetwide profiler framework
6
star
71

jupyterhub_fb_authenticator

JupyterHub Facebook Authenticator is a Facebook OAuth authenticator built on top of OAuthenticator.
Python
5
star
72

meta-fbvuln

OpenEmbedded meta-layer that allows producing a vulnerability manifest alongside a Yocto build. The produced manifest is suitable for ongoing vulnerability scanning of fielded software.
5
star
73

gazebo_lint

A Rust linter that provides various suggestions based on the new primitives offered in the `gazebo` library.
Rust
4
star
74

kernel-patches-daemon

Sync Patchwork series's with Github pull requests
Python
4
star
75

scrut

Scrut is a testing toolkit for CLI applications. A tool to scrutinize terminal programs without fuss.
Rust
4
star
76

language-capirca

Adds syntax highlighting for Capirca filetypes in Atom. Capirca is an open source standard for writing vendor-neutral firewall policies as originally released by Google: https://github.com/google/capirca
3
star
77

fbc_owrt_feed

Facebook Connectivity OpenWrt Feed. Package feed for OpenWrt router OS by Facebook Connectivity programme.
Lua
2
star
78

cutlass-fork

A Meta fork of NV CUTLASS repo.
C++
2
star