Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dev branch #30

Merged
merged 43 commits into from
Jul 17, 2018
Merged

New dev branch #30

merged 43 commits into from
Jul 17, 2018

Conversation

scurest
Copy link
Collaborator

@scurest scurest commented Jul 15, 2018

This is my new dev branch, which is not perfect, but is a significant improvement on current master, IMO, so I'm PRing it. Main new features are skinning, experimental animation support, near-complete material support, and support for four new glTF extensions (one untested).

Hopefully I can get some feedback and testing. My internet connection is not currently up to the challenge of updating my sample model repo, so I have only tested it with an old revision of the samples ^^;;;


Coordinates

  • Coordinates are hard-modified at import time, as opposed to soft-modified by eg. putting a transform at the root of the tree.

Meshes

Materials

  • Node groups are now created from serialized data in node_groups.json taken from KhronosGroup/glTF-Blender-Exporter/pbr_node/glTF2.blend. Cf. glTF import for glTF export #15 (comment).
  • Most (all?) glTF properties are now wired up in Blender.
  • COLOR_0 attributes affect the material. Fixes gltf 2.0 sample model BoxVertexColors doesn't import with vertex colors #23. The work-around for the issue I mentioned there was just to, whenever a material would have applied to both meshes with and without colors, add colors to the meshes without (this means some meshes may have a COLOR_0 that didn't in the glTF file).
  • Images are cached (so embedded images are not duplicated if used multiple times).
  • The extension KHR_materials_pbrSpecularGlossiness is supported (this was easy since the group was already in the exporter.)
  • The extension KHR_materials_unlit is supported (I wrote the group for this; it's just a simple modification of the Metallic Roughness group).
  • The extension MSFT_texture_dds is supported (Blender basically already did everything for this.)
  • The extension KHR_texture_transform is roughed in but is NOT TESTED. @sonygod

Scene Graph

  • Armatures are inserted into the scene at the points where the roots of skins are. All their children are realized as bones. This avoids my unpopular single-armature idea :)
  • Blender scenes are created for glTF scenes if this is enabled with an import option.
  • But there are problems with bones still:
    • Bone lengths are still crazy Should be okay now.
    • Bone direction is still crazy, for the sample models at least. But the bone directions make the bone tree have the same matrix at each bone as the glTF node tree does at each node.
    • Bones can't have non-unit scaling (this appears to be a Blender limitation)
    • Meshes and cameras that are children of a bone are placed in the wrong spot. I haven't figured out what transform will move them from the tail of the bone to the head yet. (This and the previous point are not a big issue for glTFs created from Blender-like scene graphs.)

Animations

  • There is experimental animation support gated behind an import option. Since there is no longer a single armature for the whole forest, a single animation may result in >1 actions, one for each object it animates. The actions are named like animation-name@object-name. To play them, select the object, open the Dope Sheet, change to Action Editor, and select the desired action. (Is there a better way to import these?)
  • Some of the animations still look wrong (eg. Monster).

Cameras

scurest and others added 30 commits March 19, 2018 12:47
This removes support for skinning.
of the Blender camera, while the `aspectRatio`, if present, affects
the resolution instead of the `angle_x` (since the latter is computed
from the `angle_y` and the resolution in Blender)
...using just one cache-lookup function instead of one for every
different type of object.
RGBA vertex colors are supported (required) by Blender 2.79 it
appears.
Based on creating first a virtual forest that mirrors the scene
graph we're about to create in Blender. Details to be documented
later... if it works out :)
Skinning is now working (again (again))...
Messy and VERY slow for the moment, but functional so I'm commiting
it for my own reference.
Comments explained the main reasoning behind the bone function.

Also switching from keyframe_points.insert to the add/co loop
gave a **huge** performance boost.
This is for faster slicing.

This doesn't make any apparent impact on import times but hopefully
it saves some memory ^^;
...because 4-component vertex colors are assumed.

Should we use some shims to papers over the Blender version
differences and get greater support? I don't have access to !=2.79
vresion atm though so it doesn't matter for now.
They don't point the right way or anything but they're there :)
But have an option to just put everything into the current scene
too (I like that better).
This prevents loading the same one multiple times.
Using the groups from the exporter, thus relieving us form writing
all our own node groups.

The group for Specular Glossiness is also part of the serialized
data, so supporting that is getting closer.
We add superfluous COLOR_0 layers to any mesh that uses a material
that is ever applied to a primitive that has a COLOR_0 attribute.
This let's us add an Attribute node to those materials without the
problem of solid red colors coming in.

COLOR_1, etc. are still not supported (well, they're imported of
course, they just don't influence the materials).
- Avoid creating dummy vnodes for meshes when possible.
- Rotate cameras to their (correct?) position
- Some slightly tighter docs.
- Some more robustness in realizing vnodes; it would probably be
  possible to use an armature for the whole forest again with minimal
  code changes
Animating non-bone locations should work now. Curve clean-up should
be working too.
The vtree beneath an armature should now be all bones except
possibly at the leaves, and we should realize them correctly(?)
now.

Also fix a typo with mesh names.
Avoids confusion with the similarly named node_groups stuff.
Support for pbrSpecularGlossiness was added here too.
Such as they are, anyway.
scurest added 13 commits July 15, 2018 02:19
- Blender automatically replaced math.inf with HUGE, so I did it
  for it
- Print a message about unknown camera types
- Setting a value on a global scene cannot possibly be the right
  thing to do with the aspect ratio -- it has to go into a property
  of the camera. Otherwise there's a race condition where only the
  last camera to get created actually changes the scene. So I backed
  that out.
- Normalized quotes.
...since it's still weird. Make the options prettier and ignore
scenes by default too.
...by using multiple attributes sets. We anticipate here, since
though there is a PR for this, it hasn't been merged into the spec
yet.
If the accessor was used again later in the glTF, we would have
seen a modified array since we hard-modified the accessor elements.
Avoid doing this.
If the joints were eg. [0,0,0,0] and the weights were [1,0,0,0],
previously we would overwrite the weight for 0 three times so it
ended up as 0. Now it will correctly be 1.
We hardly have to do anything since Blender will already handle DDS
textures so we might as well. Untested though.
I initially thought the pose TRS was computed from (final TRS) *
(rest TRS)^{-1} (ie. the opposite order of multiplication from what
I now believe is correct.) Under this scheme, the pose components
could depend on multiple final components, which required bringing
the curves under a common domain. But under the correct order of
multiplication each pose components depends only on its corresponding
final component (and the rest TRS) so that turns out to have been
over-complicated and, thank God, we can finally get rid of it!

Though, alas! it does not fix Monster.
This ensures that COLOR_0 is always the first (and ensures Blender
thinks its the default, for eg. TEXCOORD_0 and UV maps?) and avoids
any gaps in the sequence of X.
- Pick better bone lengths (when the bones are rotated the armature
  actually looks plausible now)
- Report a warning when bones had non-unit scalings in the glTF
@ksons ksons merged commit 74f8205 into ksons:master Jul 17, 2018
@ksons
Copy link
Owner

ksons commented Jul 17, 2018

Thanks! Great progress. Did not fully test everything but will look more closely before releasing 0.4.0.

@scurest
Copy link
Collaborator Author

scurest commented Jul 18, 2018

@ksons Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants