#load gltf mesh with morph targets

20 messages · Page 1 of 1 (latest)

random coral
#

I have a gltf model with animation that i made in Blender with Shape Keys (morph targets).
When i load this model as a Scene, everything works perfectly (attaching an image with what the innermost two entities look like).
I've recently decided to start loading all my models not as Scenes (#Scene0), but as Meshes (#Mesh0/Primitive0). This way I don't need to have an hierarchy with several useless entities for each Scene, and i don't need to use bevy-scene-hook.
Everything seemed to work great, but then i've encountered an issue when trying to load this particular model:

wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 180, Vulkan)>`
    In a draw command, indexed:true indirect:false
      note: render pipeline = `pbr_prepass_pipeline`
    The pipeline layout, associated with the current render pipeline, contains a bind group layout at index 2 which is incompatible with the bind group layout associated with the bind group at 2

I think it must be related to MorphWeights/MeshMorphWeights components somehow, but i'm not sure. I don't really know whether it'd be possible to have a single mesh entity with those AnimationPlayer and MorphWeights, because when I spawn it as a scene, they're not in the innermost (mesh) entity, but in its parent (refer to the screenshot)

#

load gltf mesh with morph targets

hasty cloud
#

Oh I see. Yeah you figured out the issue.

#

I didn't anticipate this use case when implementing morph targets.

#

Could you open an issuee?

random coral
#

yeah sure

hasty cloud
random coral
# hasty cloud There are two different components for morph targets. The docs should help you f...

ok, my first idea was to get the mesh, then set_morph_targets manually somehow. but then i checked with has_morph_targets and it already has them.
i did go both through these docs and also through bevy_gltf's loader.rs
there are several questions...

  • docs mention a parent entity (that normally has MorphWeights). does it mean i have to have two entities, or it can still be done with just the one (actual mesh entity)?
  • in case i do have one entity only, can't see if i need to have both MorphWeights and MeshMorphWeights there. i don't think so
  • is the precise problem that MeshMorphWeights don't get "autosynced" because there's no parent entity to sync them from?

i am now trying to directly add a MeshMorphWeights to the entity

random coral
#

..i have no idea how to grab Mesh.weights() which is a part of gltf crate

#

it sucks that i can't debug this well because it just crashes

hasty cloud
#

You need a parent entity with MorphWeights and a child entity with MeshMorphWeights

#

hmm actually, just MeshMorphWeights should be enough?

#

Wait, you want to use an animation player with this?

random coral
random coral
random coral
#

@hasty cloud if you were to help me make it work, i'd be able to put it in the issue description as a workaround 😊

hasty cloud
#

Can you write a minimal reproducible example?

random coral
#

ok i will do that