0

I've recently converted a bunch of JSON models to GLTF for playback in Three.js (exported from Blender 2.79b).

The models consist of multiple bone anims (idle, walk, run, attack, etc.) which I can access, playback, and fade between without problem.

They also contain shape keys with facial morphs for expressions and speech - 33 exist per model on average.

I have been unsuccessful at getting any of the facial morphs to play back properly.

When I keyframe a single shape key in Blender, for example in order to access facial morph number 31 out of 32 on the Dope Sheet, then animate it over time, export and play it back via the browser, it defaults to playing back whatever the first shape key is in the list. So I feel like I'm close, a facial morph is animating, just not the right one.

dopesheet

I have been struggling with figuring out how to access the proper morph. Coding is obviously not my greatest strength, but I can usually work off an example if I can find one doing something similar, in this case something that demonstrates how to access morph anim clips and then play them back alongside bone anims.

Any suggestions would be most appreciated.

aoedipus
  • 51
  • 1
  • 7
  • If you open the model on http://gltf-viewer.donmccurdy.com/, can you see and modify all 32 morphs manually? Note that three.js can only have 4-8 morph targets active at a time, depending on how it's exported... or does it seem like all morphs are working, they're just in the wrong order? – Don McCurdy Sep 24 '18 at 15:43
  • Hi Don, thanks for the quick response. When I load on your viewer (which I should have mentioned I've been doing), I do indeed see all 32 morphs (well, the first 20 at least, since Chrome won't allow me to scroll down all the way). Adjusting the sliders has no effect on any of them. The morph anim does appear in the Animation list as a separate track, and when flagged plays back the first shape key from the list - the same behavior I get in my webpages. I also get a huge number of validation errors, mostly ACCESSOR_ELEMENT_OUT_OF_MIN_BOUND and MISMATCHES – aoedipus Sep 24 '18 at 16:07
  • Hmm ok. Are you able to share the `.blend` file? This sounds like it may be a bug in the exporter, if the morph targets can't be moved even when the animation is paused or omitted. – Don McCurdy Sep 24 '18 at 17:35
  • I've posted with a reduced set of shape keys (6 total + basis) - no expressions just lip-syncs. I tested on your site and mine and the issue remains. He should be forming "vO" but defaults to the first in the list "vBmp". [bone/shapekey anim blend & gltf](http://aoedipus.net/tmp/) - I included the gltf output too. – aoedipus Sep 24 '18 at 19:09
  • I noticed that when I delete all vertex groups and materials, then export without skinning, I see the expected 6 morph targets and can modify them all nicely in the viewer... still not sure why the full export isn't working, and whether that's an exporter bug or something in your code. (can't test that case in my viewer, because there are too many mesh primitives for the UI...). Want to try hopping on https://gitter.im/KhronosGroup/glTF? This may take some discussion. – Don McCurdy Sep 25 '18 at 16:40
  • Some quick additional testing shows that it also exports and works fine when a single material is defined, but breaks with > 1 material group. For some reason the morph anims get duplicated for each material instance, which your viewer demonstrates very well in the Morph Targets listings. – aoedipus Sep 25 '18 at 22:27
  • Update: to achieve proper playback of a blender 2.79b > gltf 2.0 morph anim in three.js, I've had to constrain the exported file to include only a single material group with a single shape key edited morph anim. Any number of bone anims can be included. Sadly, this really limits synchronous skeletal and shape key animation possibilities (i.e., run cycles with expressions, gestural speech, etc.), which was how most of my models were set up. I'm also a bit surprised at how big the gltf .bin gets with a single morph anim (in my test cases jumping from ~690k to 5+MB). Maybe I'm just being dumb... – aoedipus Sep 27 '18 at 15:07
  • Progress! I think the remaining issue sounds a lot like https://github.com/KhronosGroup/glTF-Blender-Exporter/issues/100... as for size, yeah I'm surprised. If you want to file a bug we'll take a look. Disabling morph normals and using linear interpolation may help. The exporter also tends to bake keyframes aggressively, can you tell if your animation has more keyframes than intended? – Don McCurdy Sep 27 '18 at 15:19
  • in three.js you might look at `animations[0].tracks.forEach((track) => console.log(track.times + ' keyframes'));` to see how many keyframes are set for the first clip. Ideally just 3 but there are cases where it could become `numSeconds * fps` – Don McCurdy Sep 27 '18 at 23:23
  • Thanks for the debug code. Only 3 keyframes exist. File size was reduced by ~40% when morph normals were disabled on export. Yay. I still cannot get the correct morph animating (let alone multiple morphs) - it defaults to the 1st in the list. I've reposted an updated test of the blend/gltf files [blend/gltf test](http://aoedipus.net/tmp/). This behavior can be clearly seen in the viewer. When "vO" is selected from the Animation list, "vA" is the shape key playing back in the Morph Targets... yet vO is the only morph keyframed to change in Blender. I remain stumped. – aoedipus Sep 28 '18 at 21:55
  • 1
    Update for any who may be curious: I was unable to debug gltf exporter weirdness with shapeKey anims made in Blender. I have been animating the shapeKeys in Three.js instead, which gives good control and makes for smaller file sizes. – aoedipus Oct 05 '18 at 00:13

0 Answers0