Skip to content

Commit 1ef0916

Browse files
committed
Restore building for Linux.
1 parent 4f63da8 commit 1ef0916

File tree

4 files changed

+10
-350
lines changed

4 files changed

+10
-350
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ npm/fbx2gltf/node_modules/
55
npm/tests/node_modules/
66
npm/tests/test/*.js
77
npm/tests/test/*.js.map
8+
build/
9+
.cache/
10+
sdk/

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
1818
include(ExternalProject)
1919

2020
# FBX
21-
foreach (FBXSDK_VERSION "2019.2")
21+
foreach (FBXSDK_VERSION "2020.2")
2222
find_package(FBX)
2323
if (FBXSDK_FOUND)
2424
break()
@@ -57,7 +57,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5757
# DRACO
5858
ExternalProject_Add(Draco
5959
GIT_REPOSITORY https://github.com/google/draco
60-
GIT_TAG 1.3.4
60+
GIT_TAG 75b82f7b68c797b4e0ff5e73ca8a81e2db3db797
6161
PREFIX draco
6262
INSTALL_DIR
6363
CMAKE_ARGS
@@ -66,9 +66,9 @@ ExternalProject_Add(Draco
6666
)
6767
set(DRACO_INCLUDE_DIR "${CMAKE_BINARY_DIR}/draco/include")
6868
if (WIN32)
69-
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/dracoenc.lib")
69+
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib64/draco.lib")
7070
else()
71-
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/libdracoenc.a")
71+
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib64/libdraco.a")
7272
endif()
7373

7474
# MATHFU

README.md

Lines changed: 1 addition & 340 deletions
Original file line numberDiff line numberDiff line change
@@ -1,340 +1 @@
1-
# FBX2glTF
2-
3-
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
4-
5-
This is a command line tool for converting 3D model assets on Autodesk's
6-
venerable [FBX](https://www.autodesk.com/products/fbx/overview) format to
7-
[glTF 2.0](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0),
8-
a modern runtime asset delivery format.
9-
10-
Precompiled binaries releases for Windows, Mac OS X and Linux may be
11-
found [here](https://github.com/facebookincubator/FBX2glTF/releases).
12-
13-
Bleeding-edge binaries for Windows may be found [here](https://ci.appveyor.com/project/Facebook/fbx2gltf/build/artifacts). Linux and Mac OS X to come; meanwhile, you can [build your own](#building-it-on-your-own).
14-
15-
[![Build Status](https://travis-ci.com/facebookincubator/FBX2glTF.svg?branch=master)](https://travis-ci.com/facebookincubator/FBX2glTF)
16-
[![Build status](https://ci.appveyor.com/api/projects/status/5mq4vbc44vmyec4w?svg=true)](https://ci.appveyor.com/project/Facebook/fbx2gltf)
17-
18-
## Running
19-
20-
The tool can be invoked like so:
21-
22-
```
23-
> FBX2glTF ~/models/butterfly.fbx
24-
```
25-
26-
Or perhaps, as part of a more complex pipeline:
27-
28-
```
29-
> FBX2glTF --binary --draco --verbose \
30-
--input ~/models/source/butterfly.fbx \
31-
--output ~/models/target/butterfly.glb
32-
```
33-
34-
There are also some friendly & hands-on instructions available [over at Facebook](https://developers.facebook.com/docs/sharing/3d-posts/glb-tutorials/#convert-from-fbx).
35-
36-
### CLI Switches
37-
38-
You can always run the binary with --help to see what options it takes:
39-
40-
```
41-
FBX2glTF 0.9.7: Generate a glTF 2.0 representation of an FBX model.
42-
Usage: FBX2glTF [OPTIONS] [FBX Model]
43-
44-
Positionals:
45-
FBX Model FILE The FBX model to convert.
46-
47-
Options:
48-
-h,--help Print this help message and exit
49-
-v,--verbose Include blend shape tangents, if reported present by the FBX SDK.
50-
-V,--version
51-
-i,--input FILE The FBX model to convert.
52-
-o,--output TEXT Where to generate the output, without suffix.
53-
-e,--embed Inline buffers as data:// URIs within generated non-binary glTF.
54-
-b,--binary Output a single binary format .glb file.
55-
--long-indices (never|auto|always)
56-
Whether to use 32-bit indices.
57-
--compute-normals (never|broken|missing|always)
58-
When to compute vertex normals from mesh geometry.
59-
--anim-framerate (bake24|bake30|bake60)
60-
Select baked animation framerate.
61-
--flip-u Flip all U texture coordinates.
62-
--no-flip-u Don't flip U texture coordinates.
63-
--flip-v Flip all V texture coordinates.
64-
--no-flip-v Don't flip V texture coordinates.
65-
--no-khr-lights-punctual Don't use KHR_lights_punctual extension to export FBX lights.
66-
--user-properties Transcribe FBX User Properties into glTF node and material 'extras'.
67-
--blend-shape-normals Include blend shape normals, if reported present by the FBX SDK.
68-
--blend-shape-tangents Include blend shape tangents, if reported present by the FBX SDK.
69-
-k,--keep-attribute (position|normal|tangent|binormial|color|uv0|uv1|auto) ...
70-
Used repeatedly to build a limiting set of vertex attributes to keep.
71-
--fbx-temp-dir DIR Temporary directory to be used by FBX SDK.
72-
73-
74-
Materials:
75-
--pbr-metallic-roughness Try to glean glTF 2.0 native PBR attributes from the FBX.
76-
--khr-materials-unlit Use KHR_materials_unlit extension to request an unlit shader.
77-
78-
79-
Draco:
80-
-d,--draco Apply Draco mesh compression to geometries.
81-
--draco-compression-level INT in [0 - 10]=7
82-
The compression level to tune Draco to.
83-
--draco-bits-for-position INT in [1 - 32]=14
84-
How many bits to quantize position to.
85-
--draco-bits-for-uv INT in [1 - 32]=10
86-
How many bits to quantize UV coordinates to.
87-
--draco-bits-for-normals INT in [1 - 32]=10
88-
How many bits to quantize nornals to.
89-
--draco-bits-for-colors INT in [1 - 32]=8
90-
How many bits to quantize colors to.
91-
--draco-bits-for-other INT in [1 - 32]=8
92-
How many bits to quantize all other vertex attributes to.
93-
```
94-
95-
Some of these switches are not obvious:
96-
97-
- `--embed` is the way to get a single distributable file without using the
98-
binary format. It encodes the binary buffer(s) as a single base64-encoded
99-
`data://` URI. This is a very slow and space-consuming way to accomplish what
100-
the binary format was invented to do simply and efficiently, but it can be
101-
useful e.g. for loaders that don't understand the .glb format.
102-
- `--flip-u` and `--flip-v`, when enabled, will apply a `x -> (1.0 - x)`
103-
function to all `u` or `v` texture coordinates respectively. The `u` version
104-
is perhaps not commonly used, but flipping `v` is **the default behaviour**.
105-
Your FBX is likely constructed with the assumption that `(0, 0)` is bottom
106-
left, whereas glTF has `(0, 0)` as top left. To produce spec-compliant glTF,
107-
we must flip the texcoords. To request unflipped coordinates:
108-
- `--long-indices` lets you force the use of either 16-bit or 32-bit indices.
109-
The default option is auto, which make the choice on a per-mesh-size basis.
110-
- `--compute-normals` controls when automatic vertex normals should be computed
111-
from the mesh. By default, empty normals (which are forbidden by glTF) are
112-
replaced. A choice of 'missing' implies 'broken', but additionally creates
113-
normals for models that lack them completely.
114-
- `--no-flip-v` will actively disable v coordinat flipping. This can be useful
115-
if your textures are pre-flipped, or if for some other reason you were already
116-
in a glTF-centric texture coordinate system.
117-
- All three material options are, in their own way, works in progress, but the
118-
`--pbr-metallic-roughness` switch is at least compliant with the core spec;
119-
unlike the others, it does not depend on an unratified extension. That option
120-
will be chosen by default if you supply none of the others. Material switches
121-
are documented further below.
122-
- If you supply any `-keep-attribute` option, you enable a mode wherein you must
123-
supply it repeatedly to list _all_ the vertex attributes you wish to keep in
124-
the conversion process. This is a way to trim the size of the resulting glTF
125-
if you know the FBX contains superfluous attributes. The supported arguments
126-
are `position`, `normal`, `tangent`, `color`, `uv0`, and `uv1`.
127-
- When **blend shapes** are present, you may use `--blend-shape-normals` and
128-
`--blend-shape-tangents` to include normal and tangent attributes in the glTF
129-
morph targets. They are not included by default because they rarely or never
130-
seem to be correctly present in the actual FBX source, which means the SDK
131-
must be computing them from geometry, unasked? In any case, they are beyond
132-
the control of the artist, and can yield strange crinkly behaviour. Since
133-
they also take up significant space in the output file, we made them opt-in.
134-
135-
## Building it on your own
136-
137-
We currently depend on the open source projects
138-
[Draco](https://github.com/google/draco),
139-
[MathFu](https://github.com/google/mathfu),
140-
[Json](https://github.com/nlohmann/json),
141-
[cppcodec](https://github.com/tplgy/cppcodec),
142-
[CLI11](https://github.com/CLIUtils/CLI11),
143-
[stb](https://github.com/nothings/stb),
144-
and [fmt](https://github.com/fmtlib/fmt);
145-
all of which are automatically downloaded and/or built.
146-
147-
**At present, only version 2019.2 of the FBX SDK is supported**. The
148-
build system will not successfully locate any other version.
149-
150-
### Linux and MacOS X
151-
152-
Your development environment will need to have:
153-
154-
- build essentials (gcc for Linux, clang for Mac)
155-
- cmake
156-
- python 3.\* and associated pip3/pip command
157-
- zstd
158-
159-
Then, compilation on Unix machines will look something like:
160-
161-
```
162-
# Determine SDK location & build settings for Linux vs (Recent) Mac OS X
163-
> if [[ "$OSTYPE" == "darwin"* ]]; then
164-
export CONAN_CONFIG="-s compiler=apple-clang -s compiler.version=10.0 -s compiler.libcxx=libc++"
165-
export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Darwin/archive/2019.2.tar.gz"
166-
elif [[ "$OSTYPE" == "linux"* ]]; then
167-
export CONAN_CONFIG="-s compiler.libcxx=libstdc++11"
168-
export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Linux/archive/2019.2.tar.gz"
169-
else
170-
echo "This snippet only handles Mac OS X and Linux."
171-
fi
172-
173-
# Fetch Project
174-
> git clone https://github.com/facebookincubator/FBX2glTF.git
175-
> cd FBX2glTF
176-
177-
# Fetch and unpack FBX SDK
178-
> curl -sL "${FBXSDK_TARBALL}" | tar xz --strip-components=1 --include */sdk/
179-
# Then decompress the contents
180-
> zstd -d -r --rm sdk
181-
182-
# Install and configure Conan, if needed
183-
> pip3 install conan # or sometimes just "pip"; you may need to install Python/PIP
184-
> conan remote add --force bincrafters https://api.bintray.com/conan/bincrafters/public-conan
185-
186-
# Initialize & run build
187-
> conan install . -i build -s build_type=Release ${CONAN_CONFIG}
188-
> conan build . -bf build
189-
```
190-
191-
If all goes well, you will end up with a statically linked executable in `./build/FBX2glTF`.
192-
193-
### Windows
194-
195-
<TODO> the below is out of date
196-
197-
Windows users may [download](https://cmake.org/download) CMake for Windows,
198-
install it and [run it](https://cmake.org/runningcmake/) on the FBX2glTF
199-
checkout (choose a build directory distinct from the source).
200-
201-
As part of this process, you will be asked to choose which generator
202-
to use. **At present, only Visual Studio 2017 or 2019 is supported.** Older
203-
versions of the IDE are unlikely to successfully build the tool.
204-
205-
Note that the `CMAKE_BUILD_TYPE` variable from the Unix Makefile system is
206-
entirely ignored here; it is when you open the generated solution that
207-
you will be choose one of the canonical build types — _Debug_,
208-
_Release_, _MinSizeRel_, and so on.
209-
210-
## Conversion Process
211-
212-
The actual translation begins with the FBX SDK parsing the input file, and ends
213-
with the generation of the descriptive `JSON` that forms the core of glTF, along
214-
with binary buffers that hold geometry and animations (and optionally also
215-
emedded resources such as textures.)
216-
217-
In the process, each mesh is ripped apart into a long list of triangles and
218-
their associated vertices, with a material assigned to each one. A similar
219-
process happens in reverse when we construct meshes and materials that conform
220-
to the expectations of the glTF format.
221-
222-
### Animations
223-
224-
Every animation in the FBX file becomes an animation in the glTF file. The
225-
method used is one of "baking": we step through the interval of time spanned by
226-
the animation, keyframe by keyframe, calculate the local transform of each
227-
node, and whenever we find any node that's rotated, translated or scaled, we
228-
record that fact in the output.
229-
230-
Beyond skeleton-based animation, _Blend Shapes_ are also supported; they are
231-
read from the FBX file on a per-mesh basis, and clips can use them by varying
232-
the weights associated with each one.
233-
234-
The baking method has the benefit of being simple and precise. It has the
235-
drawback of creating potentially very large files. The more complex the
236-
animation rig, the less avoidable this data explosion is.
237-
238-
There are three future enhancements we hope to see for animations:
239-
240-
- Version 2.0 of glTF brought us support for expressing quadratic animation
241-
curves, where previously we had only had linear. Not coincidentally, quadratic
242-
splines are one of the key ways animations are expressed inside the FBX. When
243-
we find such a curve, it would be more efficient to output it without baking
244-
it into a long sequence of linear approximations.
245-
- We do not yet ever generate
246-
[sparse accessors](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#sparse-accessors),
247-
but many animations (especially morph targets) would benefit from this
248-
storage optimisation.
249-
- Perhaps most useful in practice is the idea of compressing animation curves
250-
the same way we use Draco to compress meshes (see below). Like geometry,
251-
animations are highly redundant — each new value is highly predictable from
252-
preceding values. If Draco extends its support for animations (it's on their
253-
roadmap), or if someone else develops a glTF extension for animation
254-
compression, we will likely add support in this tool.
255-
256-
### Materials
257-
258-
With glTF 2.0, we leaped headlong into physically-based rendering (PBR), where
259-
the canonical way of expressing what a mesh looks like is by describing its
260-
visible material in fundamental attributes like "how rough is this surface".
261-
262-
By contrast, FBX's material support remains largely in the older world of
263-
Lambert and Phong, with simpler and more direct illumination and shading
264-
models. These modes are inherently incompatible — for example, textures in the
265-
old workflow often contain baked lighting of the type that would arise naturally
266-
in a PBR environment.
267-
268-
Some material settings remain well supported and transfer automatically:
269-
270-
- Emissive constants and textures
271-
- Occlusion maps
272-
- Normal maps
273-
274-
This leaves the other traditional settings, first of Lambert:
275-
276-
- Ambient — this is anathema in the PBR world, where such effects should
277-
emerge naturally from the fundamental colour of the material and any ambient
278-
lighting present.
279-
- Diffuse — the material's direction-agnostic, non-specular reflection,
280-
and additionally, with Blinn/Phong:
281-
- Specular — a more polished material's direction-sensitive reflection,
282-
- Shininess — just how polished the material is; a higher value here yields a
283-
more mirror-like surface.
284-
285-
(All these can be either constants or textures.)
286-
287-
#### Exporting as Unlit
288-
289-
If you have a model was constructed using an unlit workflow, e.g. a photogrammetry
290-
capture or a landscape with careful baked-in lighting, you may choose to export
291-
it using the --khr-materials-common switch. This incurs a dependency on the glTF
292-
extension 'KHR_materials_unlit; a client that accepts that extension is making
293-
a promise it'll do its best to render pixel values without lighting calculations.
294-
295-
**Note that at the time of writing, this glTF extension is still undergoing the
296-
ratification process**
297-
298-
#### Exporting as Metallic-Roughness PBR
299-
300-
Given the command line flag --pbr-metallic-roughness, we throw ourselves into
301-
the warm embrace of glTF 2.0's PBR preference.
302-
303-
As mentioned above, there is little consensus in the world on how PBR should be
304-
represented in FBX. At present, we support only one format: Stingray PBS. This
305-
is a feature that comes bundled with Maya, and any PBR model exported through
306-
that route should be digested propertly by FBX2glTF.
307-
308-
(A happy note: Allegorithmic's Substance Painter also exports Stingray PBS,
309-
when hooked up to Maya.)
310-
311-
## Draco Compression
312-
313-
The tool will optionally apply [Draco](https://github.com/google/draco)
314-
compression to the geometric data of each mesh (vertex indices, positions,
315-
normals, per-vertex color, and so on). This can be dramatically effective
316-
in reducing the size of the output file, especially for static models.
317-
318-
Enabling this feature adds an expressed required dependency in the glTF on the
319-
`KHR_draco_geometry_compression` extension, and can thus only be loaded by a
320-
viewer that is willing and able to decompress the data.
321-
322-
**Note that at the time of writing, this glTF extension is still undergoing the
323-
ratification process.**
324-
325-
## Future Improvements
326-
327-
This tool is under continuous development. We do not have a development roadmap
328-
per se, but some aspirations have been noted above. The canonical list of active
329-
TODO items can be found
330-
[on GitHub](https://github.com/facebookincubator/FBX2glTF/labels/enhancement).
331-
332-
## Authors
333-
334-
- Pär Winzell
335-
- J.M.P. van Waveren
336-
- Amanda Watson
337-
338-
## License
339-
340-
FBX2glTF is licensed under the [3-clause BSD license](LICENSE).
1+
# FBXSDK-Linux

0 commit comments

Comments
 (0)