AmbientRun / Ambient

The multiplayer game engine
https://ambient.run
Apache License 2.0
3.8k stars 124 forks source link

Panic when skinned mesh has a bone which drives a blend shape/morph target (GLTF and FBX) #371

Open alfredbaudisch opened 1 year ago

alfredbaudisch commented 1 year ago

If a skinned mesh has a bone that drives a blend shape / morph target, either GLTF or FBX, the asset is not imported.

The bone is keyframed only on Location and drives a blend shape value from 0 to 1.

https://user-images.githubusercontent.com/248383/236671476-e1d807ff-2da9-4f38-8ff4-bbc694d25d75.mp4

GLTF Error

thread 'tokio-runtime-worker' panicked at 'not implemented', <...>\7daa5ef\crates\model_import\src\gltf\mod.rs:109:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2023-05-07T10:13:10Z ERROR ambient_build] In pipeline pipeline.json/0, at file AnimationDriver.glb

    Caused by:
        task 30 panicked

FBX Error

thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', crates\model_import\src\fbx\mesh.rs:115:108
[2023-05-07T10:13:10Z ERROR ambient_build] In pipeline pipeline.json/0, at file AnimationDriver.fbx

    Caused by:
        task 29 panicked

Tried to load in the skinmesh sample:

const START: (&str, &str) = (
    "TurnOnMachine",
    "assets/AnimationDriver.glb/animations/TurnOnMachine.anim",
);
const END: (&str, &str) = ("TurnOnMachine", "assets/AnimationDriver.glb/animations/TurnOnMachine.anim");

  let unit_id = Entity::new()
      .with_merge(make_transformable())
      .with(
          prefab_from_url(),
          asset::url("assets/AnimationDriver.glb").unwrap(),
      )
      .with(name(), "Machine".to_string())
      .spawn();

Example

.blend, fbx and gltf sample files: AnimationDriveBlendShapeBone.zip

This mesh contains a very simple armature with one animation "TurnOnMachine" that moves on the Y up and down, and drives the blend shape "TurnOn" of this cube (from the sample GIF above).

Validation

As a validation, here's the model in the Khrono's glTF Viewer:

https://user-images.githubusercontent.com/248383/236680315-634c3b99-21af-440d-afd7-33d2197bedcb.mp4

philpax commented 1 year ago

Thanks for reporting this! We'll look into it.

philpax commented 1 year ago

Looked into this; it appears morph targets are not currently implemented.

@FredrikNoren Looks like we need your input on this one, too. Are morph targets planned?

FredrikNoren commented 1 year ago

@philpax Not in the immediate future. @alfredbaudisch (or anyone else interested in it) if you'd like to take a stab at implementing morph targets we would be happy to review a PR for it.