Commit Graph

264 Commits

Author SHA1 Message Date
Pär Winzell 2fc254ed79
Update example command-line switch 2018-09-08 11:35:10 -07:00
Matt Brown 9c84e14ddc fixed typo in Describe function for specular 2018-08-19 18:24:52 -07:00
Pär Winzell bdcf16f042
Trivial typo fix.
Thanks to @ale64bit for pointing this out.
2018-08-19 18:24:16 -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
Darío Hereñú 447333a16a Typo on string #239, #241, #244 2018-04-26 07:21:02 -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 cb76a49b82 List all sources in CMakeLists.txt.
If nothing else, it helps IDEs do the right thing.
2018-04-08 15:47:27 -07:00
Par Winzell 3bfe56b71f Minor Windows fixes. 2018-03-29 06:46:19 -07:00
Par Winzell 542550192c Bump NPM version, 2018-03-29 06:24:46 -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
Pär Winzell 93d1385b1e
Fix typo & markdown error. 2018-03-18 09:42:04 -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
Pär Winzell f1982e6ca3 Bump NPM version. 2018-02-19 20:59:44 -08:00
Par Winzell da5d606c93 Documentation tweaks. 2018-02-19 20:15:01 -08:00
Par Winzell 608c6f1797 Add support for 32-bit indices.
This was way overdue. Breaking up large meshes into many 65535-vertex
primitives can save a few bytes, but it's really a lot of complication
for minor benefit.

With this change the user can force short or long indices, and the
default is to use shorts for smaller meshes and longs for longer.
2018-02-19 13:58:09 -08:00
Par Winzell 0deaf186a8 Some basic .gitignore stuff. 2018-02-19 09:32:25 -08:00
Par Winzell 7c0715c4ad Clean house in material extensions.
- KHR_materials_common never had a real life in the glTF 2.0 world. One
day we may see a new extension for Phong/Blinn/Lambert.
- PBR_specular_glossiness is a poor fit for PBS StingRay (the only real
source of PBR we have) and has no advantage over PBR_metallic_roughness.
- The conversion we were doing for traditional materials to PBR made no
sense. Revert to a very simple formula: diffuse -> baseColor, simple
reasonable constants for metallic & roughness.
2018-02-19 08:57:19 -08:00
Par Winzell 67bb9372d7 Optionally compute normals from geometry.
The user can now ask for normals to be computed NEVER (can easily cause
broken glTF if the source isn't perfect), MISSING (when the mesh simply
lacks normals), BROKEN (only emptuy normals are replaced), or
ALWAYS (perhaps if the normals in the source are junk).
2018-02-18 22:19:24 -08:00
Par Winzell b95c50a72f Code to repair normals. 2018-02-18 14:42:30 -08:00
Par Winzell 20b1bd7051 Semi-randomly tweak Phong->PBR conversion.
I stole expressions from Gary Hsu's PBR conversion routines here:

3606e79717/extensions/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows/js/three.pbrUtilities.js

which is experimental enough as it is, but I had gone further into the
domain of madness and uses this with *old* diffuse/specular values, not
PBR specular/glossness.

As a result a lot of old content was coming up with 100% metal values
quite often, which in turn means completely ignoring diffuse when
assembling a new base colour...

I should rip out this whole conversion. But not just now...
2018-02-04 14:42:57 -08:00
Par Winzell 54c3b04fce Cope with degenerate node T/R/S.
It's technically valid for e.g. scale to have a zero dimension, which in
turn wreaks havoc on the rotation quaternion we get from the FBX SDK.

The simplest solution is to just leave any T/R/S vector out of the glTF
if it has any NaN component.
2018-02-02 11:12:06 -08:00
Par Winzell a3989249f3 Consistent naming of unlit extension use. 2018-02-02 07:08:00 -08:00
Par Winzell 8ab9459d6a Don't override encoder's best guess. 2018-02-02 06:58:47 -08:00
Par Winzell cbd2e3f00d Use newer Draco. 2018-02-02 06:58:17 -08:00
Robert Long 74479426a7 KHR_materials_unlit (#61)
KHR_materials_unlit support.
2018-02-02 06:57:36 -08:00
Par Winzell 41f8a5ef03 Improvements in texture merging.
Be more flexible about reading various input formats (most especially
varying numbers of channels), and stop outputting RGBA PNGs for textures
that don't need it.

I'm not sure JPG generation ever worked right. But now it does.
2017-12-22 16:02:48 -08:00
David Ávila a2d5c7d87b Fix duplicate name issues (#51)
Fix the naming issues. Now the nodes are identified by pNode->GetUniqueID(), instead of its name. All dictionaries and references to nodes are replaced by its id, instead of its name.
2017-12-06 10:43:18 -08:00
Pär Winzell 13367dfc66
Merge pull request #50 from msfeldstein/master
Pass camera reference through propertly as index uints, not as (glTF 1.0 era) name strings.
2017-12-04 22:18:49 -08:00
Mike Feldstein 9d1096f3ff Properly pass camera data through 2017-12-04 14:35:57 -08:00
Pär Winzell cc0a6e5b89
Merge pull request #48 from davilovick/fix_normal_issues 2017-12-03 11:58:09 -08:00
David Ávila Membrives 1a46ccf7ff Include meshScaling in normal transform 2017-12-03 20:47:41 +01:00
David Ávila Membrives 9c2e485cfc Apply the correct transform on normals (remove transform & scaling components) 2017-12-03 15:32:53 +01:00
Pär Winzell a9c4fb1bd0 Fix for Windows. (And generally a good idea.) 2017-11-30 23:15:13 -08:00