Commit Graph

109 Commits

Author SHA1 Message Date
Par Winzell d451aa73f3 Delete obsolete classes, poke at Physical Material support.
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.)
2019-01-16 13:52:33 -08:00
Par Winzell 1328a4b96f Another, better argument parsing fix. 2019-01-11 20:47:08 -08:00
Par Winzell 5c07d274c3 Fix broken U/V flipping. 2019-01-11 19:38:33 -08:00
Par Winzell 1145defda3 Use case-insensitive matching on old shader types. 2018-12-19 14:22:58 -08:00
Pär Winzell 5730d1c301
Apply clang-format to all our source. (#149)
Apply clang-format to all our source.
2018-12-18 23:30:29 -08:00
Pär Winzell be1b75431d
Switch from CXXOPTS to CLI11. (#148)
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).
2018-12-17 16:13:53 -08:00
Par Winzell 5389d848e2 Implement KHR_lights_punctual. 2018-12-17 10:21:43 -08:00
Par Winzell 49892c5e83 Abstract out user property serialisation. 2018-12-14 00:05:43 -08:00
Graham Wihlidal f2cb6a1010 Fix various tabs vs spaces formatting inconsistencies 2018-12-13 23:00:05 -08:00
Graham Wihlidal 8b081a5fc3 Implemented support for exporting user properties assigned to materials 2018-12-13 23:00:05 -08:00
Par Winzell 7374bcf34f No default argument in implementation. 2018-12-12 12:46:45 -08:00
Pär Winzell 62bb8710c0 Fix cross-platform path handling.
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.
2018-12-07 09:40:21 -08:00
Par Winzell 2029fa7277 Delete unused variable. 2018-12-02 19:02:24 -08:00
Par Winzell a65628f56f Specify that we want std::isnan().
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.
2018-12-02 19:00:42 -08:00
Pär Winzell c34f861f69 Don't force RTTI for one measly cast. 2018-10-28 16:03:52 -07:00
Michael Ranieri d38ccd935f fix fov computation from fbxsdk (#133)
* fix fov computation from fbxsdk
2018-10-22 18:32:20 -07:00
Michael Ranieri efd404764d Fix camera rotation from FBX, fix illegal memory access of binary data 2018-10-19 01:05:48 -07:00
Pär Winzell 319c0fe460 Wrap user properties in a command line option. 2018-10-14 21:46:49 -07:00
Pär Winzell bbbba646de Massive reorganisation.
This finishes the first phase of the FBX2glTF refactor, breaking utility classes out where things were getting too monolithic.

There is an equally important cleanup phase coming where we wrench all the various parts of this code, including the historical ones that we've rarely touched as yet, into a single C++ style paradigm, and modernise everything to C++11 at least.

But for now, we're just picking the pieces back on the floor so we can push 0.9.6 out. It's been far too long since a release.
2018-10-13 20:15:12 -07:00
Par Winzell 2a4da70de0 Make the JSON library ambiently available. 2018-10-13 19:25:18 -07:00
Michael Ranieri 2e03a3cdea Transcribe FBX Custom Properties 2018-10-13 19:23:48 -07:00
Par Winzell f646be2e47 Both DIFFUSE and ALBEDO can dictate transparency. 2018-10-02 16:59:41 -07:00
Artem Titoulenko 5282f693f9 Blend shape keys to accessor names (#122)
Map blendshape keys to accessor names
2018-09-25 16:09:18 -07:00
Pär Winzell 52de0d20d8
Typo fix on Fbx2Raw.cpp
Thanks @fire for the report. Fixes #128.
2018-09-24 20:24:30 -07:00
Par Winzell f988cb7aa7 Missing bits, oops.
Did not mean to commit/push the current state of master. But rather than
mess up source control history with a force push, I'll just try to hurry
to a stable point.
2018-09-13 17:21:57 -07:00
Par Winzell 7d36e7f4d7 Rearrange, extract, clean up.
Hopefully without unintentional changes to functionality. This renames header
files to .hpp, imposes a gltf/raw/fbx directory structure, extracts standalone
chunks of Fbx2Raw into distinct files, and undoes some particularly egregious
mistakes from when I knew even less C++ than I do now.

This is in anticipation of implementing 3ds Max's "Physical Material".
2018-09-13 16:55:24 -07:00
Matt Brown 9c84e14ddc fixed typo in Describe function for specular 2018-08-19 18:24:52 -07:00
Pär Winzell 7995f7b341 Resolve _WIN32 isnan() fiasco completely. 2018-05-27 13:28:49 -07:00
Par Winzell d3f9a269ba Customisable Draco encoding options. 2018-05-08 09:01:58 -07:00
Par Winzell 5788eea8ad Don't tell me you did nothing. 2018-05-03 18:58:58 -07:00
Par Winzell e178a75be3 Start tracking and using FBX2glTF version. 2018-05-03 18:51:35 -07:00
Par Winzell 3c8cad4730 Fix crash from dangling surface reference.
The condense operation recreates the vectors of surfaces, materials,
textures and vertices so as to exclude anything that isn't referenced
explicitly by a triangle. In the process, we must take care that
references from other properties are cleared out.

This fixes the case when a node references a mesh by id, and then the
mesh is deleted because no triangle references. TODO: go through other
properties and make sure the same problem doesn't exist there.

It is also possible that these vectors should be replaced by maps, at
least for the elements that (now) have unique IDs.
2018-05-03 14:44:43 -07:00
Par Winzell f530af8bf4 Use std:: whenever possible. 2018-05-03 08:21:42 -07:00
Par Winzell 68983ad0d0 Fix skinning edge case.
A mesh with a single (skinning) deformer which had zero clusters would
erroneously register as skinned, leading GetRoodNode() to an assertion
failure. Fixed.
2018-04-08 17:54:42 -07:00
Par Winzell 3bfe56b71f Minor Windows fixes. 2018-03-29 06:46:19 -07:00
Par Winzell 9174fe2f50 Fixes and improvements to shininess -> roughness. 2018-03-29 05:49:40 -07:00
Par Winzell b3492194cf Slightly better Blinn/Phong -> PBR.
We're still gunshy from our previous attempts at coming up with metalilc
and roughness values from diffuse/specular/shininess, but this should be
safe: a high shininess means a low roughness, and vice versa.
2018-03-28 10:44:51 -07:00
Par Winzell 3f1590a26b Don't be tricksy if we're already done.
The FBX SDK looks for our textures and often finds them. It helpfully
tells us exactly where they are. Let's not throw that information away
and demand that the textures only exist in precisely the folders we are
aware of.
2018-03-27 20:00:48 -07:00
Par Winzell e992aac1d9 Mark glTF materials with FBX origins.
Because we make a best-effort attempt to convert materials on the old
form -- like :ambert and Phong -- to PBR materials, it can be beneficial
to the consumer of the asset to know if the asset was intentionally
authored as PBR, or if it was a conversion.

The precise details of this information is specific to the intersection
of FBX and glTF, so we're not going to bother proposing extensions; we
just drop something into the extras field, e.g.

    "materials": [
        {
            "name": "Troll_Water",
            "alphaMode": "OPAQUE",
            "extras": {
                "fromFBX": {
                    "shadingModel": "Metallic/Roughness",
                    "isTruePBR": true
                }
            },
        // ... and so on.

The possible values for shadingModel are:
    "<unknown>"
    "Constant"
    "Lambert"
    "Blinn"
    "Phong"
    "Metallic/Roughness"

Currently isTruePBR is true for the final entry, false for the other.
However, we may well add more PBR shading models in the future, so if
you intend to use this feature to look for true PBR, use the derived
property.
2018-03-27 19:31:01 -07:00
Par Winzell ca12a38afe Always eliminate the 0.01 factor. 2018-03-27 14:54:36 -07:00
PLAINCONCEPTS\davila 4ec8c8e34d Change the way that unit conversion affects the scene. 2018-03-27 14:17:33 -07:00
Par Winzell f6ce7e345d Keep our byte-writing within bounds.
Now that we're writing both 16-bit and 32-bit integers, it's starting to
matter a little more how we slam even scalars into memory. This is maybe
not the fastest way to accomplish this, and I'm not crazy about the way
GLType works in general, but it does have the virtues of clarity and
expediency.
2018-03-27 11:26:50 -07:00
Josh Faust e92261f491 Fix Image_Utils.h to include <algorithm> 2018-03-01 10:50:57 -08:00
Par Winzell c72cf85acf Small oops left over from glTF 1.0. 2018-02-25 19:40:22 -08:00
Pär Winzell dc8f199d54
Support occlusion texture all the way. (#81)
By oversight we had not included occlusionTexture in the core
MaterialData. While we're at it, bake occlusion into the red channel of
the merged metallic/roughness texture.
2018-02-25 18:35:04 -08:00
Pär Winzell 362b8bd761
Clamp FBX values to glTF specifications (#80)
There seem to be few constraints on what values FBX properties can take. By contrast, glTF constrains e.g. common material factors to lie in [0, 1]. We take a simple approach and just clamp.
2018-02-25 18:13:19 -08:00
Pär Winzell a8f194f793
better texture transparency test (#78)
Previous to this, a PNG that was on RGBA format would cause its
corresponding texture to be flagged as transparent. This is very
silly. We now iterate over the bytes, and if any is not 255, THEN
there's alpha.
2018-02-25 17:28:26 -08:00
Pär Winzell a984f7bf37
Drop the Gltf:: namespace prefix. (#77) 2018-02-25 17:19:19 -08:00
Pär Winzell 3f796dd90f
Use a tiny PNG for a fallback texture image, not a GIF (#74) 2018-02-23 19:39:08 -08:00
Par Winzell da5d606c93 Documentation tweaks. 2018-02-19 20:15:01 -08:00