Skip to content

GLTF Morph Targets #5756

@willstott101

Description

@willstott101

What problem does this solve or what need does it fill?

Bevy supports skeletal animation but not morph-target animation. Morph target animation is widely used for face animation rigs and is actually much simpler mathematically than skeletal animation, but requires a larger amount of memory.

What solution would you like?

Bevy should (in order of criticality):

  • Load GLTF mesh primitive's morph targets into vertex attributes CPU-side
  • Load the initial weights stored on GLTF Mesh nodes into a bevy mesh struct
    ** Morph target names tend to be stored in "extras"."targetNames" in GLTF files
    ** Providing an API for enumerating available targets would be very useful
  • Provide a CPU-side API for blending Meshes with morph targets (then up to users to update in the scene)
    ** This can be useful for raycasting and cpu-side scene exporting etc even when GPU-morphing is implemented
  • Provide GPU-side morph blending with the help of a shape gains uniform on Mesh objects

What alternative(s) have you considered?

An outside plugin to handle this would - as far as I understand it - require duplicating much of the work the existing GLTF loader does. Once loading is possible, CPU blending could be a third-party plugin I am sure.

For integration into the rendering pipeline (GPU-side blending) and other plugins, I think Bevy having an understanding of morph targets right down in it's Mesh primitives will prove very valuable.

Additional context

I'd be quite interested to have a tinker into some work on this front - however guidance into the intended APIs around Mesh/SkinnedMesh would help me be confident to open a PR for at least part of this work. I don't think I have the knowledge or time to try and integrate into the shaders and standard pipeline properly.

three.js for instance supports morph targets as part of it's root Mesh class: Mesh.morphTargetInfluences and supports CPU morphing BufferGeometryUtils.computeMorphedAttributes despite generally performing morphing in shaders: morphtarget_vertex.glsl.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AnimationMake things move and change over timeC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions