Alright, less haphazardly now after the two previous botched commits,
this fixes mistakes and bugs made a year or more in the past:
- We now always pass the metallic and roughness factors through all
the way to the glTF layer. They should not be multiplied into the
generated textures, and so they should be present as-is in glTF
output.
- We only generate the AO/Rough/Net combined texture if at least two
of the constituent textures are present.
- We only reference the generated texture as an occlusionTexture if
there really was an occlusion map present (and it had non-trivial
pixels).
It's also now ridiculously clear that:
- The material conversion section is long and tortured and it's very
easy to screw up. It should be broken into functions and classes.
- We urgely need a real regression suite, and we need to model some
artificial FBX files that test both realistic scenarios and edge-
case permutations.
At the end of the various material/mesh transformations we do, we were still using a ridiculously simplistic method of mapping RawMaterial to glTF MaterialData.
This switches to using FBX's GetUniqueID(), which should be the law of the land in general. Other model entities may need further investigation as well.
This moves ./npm to ./npm/fbx2gltf, and introduces a Mocha / TypeScript based testing harness.
We're also adding a GIT LFS dependency, but only for people who want to run tests. We're using LFS to store the many FBX models we want to convert to GLB as part of the integration test suite.
There's still work to be done here, mainly:
- Convert BUMP to NORMAL
- Apply "roughness inversion" to roughness map
But it now informs the user of unsupported properties their model uses,
and generally works correctly!
We don't want to use the logical texture name from the FBX to distinguish separate textures. It seems entirely valid for distinct textures to have the same name. It's not completely clear what's best to use instead, but adding fileLocation seems reasonable. It can be blank, for textures that don't exist on the filesystem –– but that's a pretty weird edge case, and even then we have both 'usage' and 'name' to distinguish.
Looks like I never did the required cleanup after my accidental commit back in August.
This deletes the materials classes that were obsoleted back then, and comments out the
large swathes of PhysicalMaterial code that's not currently doing anything (i.e. all the
materials properties that glTF can't currently represent.)
We want to move to auto-formatting all our code, and it just seemed impossible
to make cxxopts usage tidy under clang-format's dominion. While trying to work
out its quirks, I realised that CLI11 did everything I wanted much better, and
so we've switched.
We're also going to chuck the usage of ExternalProject_Add(), at least for the
simplest use cases such as single-header include files. We'll just commit them
directly; that's kind of the whole point.
The one discipline we'll maintain is that commits that involve third_party/
should be as self-contained as possible (without breaking the app).
This is a recreation of the PR @robertlong submitted long ago here:
https://github.com/facebookincubator/FBX2glTF/pull/97
Refactors and whitespace conflicts made this easier.
There is still a substantial rewrite of the texture-loading and
file-path handling pending, for sometime soon.
Depending on platform, multiple versions of isnan() can easily be floating around, causing compilation headaches. Luckily we can always rely on the standard library implementation.