There are a few issues with animation (skeletal animation and blend shapes) that could be improved:
- The animation machinery is tied to
Model. You can't animate a Mesh without implementing your own animation system.
- You can't share animation state between different Model objects right now.
- Having to clone Models to get different animation states is clunky.
Some ideas for improvements:
- Add a
Skeleton object:
- It contains:
- List of joint transforms
- An inverse bind matrix for each joint
- Possibly joint names
- No keyframe/animation info
- No blend shapes
- Similar to how
Mesh can have a Material attached, it can have a Skeleton attached too, which is used to animate its vertices.
- There are new builtin vertex attributes you can add,
VertexJoint and VertexWeight, used for skinning.
- (While we're here we might want to make it possible to have multiple vertex buffers on a mesh).
Model probably creates a default skeleton, but it can be changed with e.g. Model:setSkeleton.
Model:animate continues to exist and sets joint transforms on the Model's skeleton.
- Add a generic system for animated draws in Pass. Pass probably stores a list of its animated draws, which is like a draw index, a skeleton, and mesh info. It can use this to batch all of the animation dispatches on submit, which provides some opportunities to improve performance / reduce memory usage (pooling, culling, temp buffer data for skinned vertices).
- For blend shapes, Mesh could probably get a "blend shape count" declared when it's created, and then there could be methods to set data for a given blend shape index and vertex index, along with the weight for each blend shape.
Should this be implemented? Meh. It's kind of a high effort task for medium-level payoff, but it does clean up the animation stuff a lot.
There are a few issues with animation (skeletal animation and blend shapes) that could be improved:
Model. You can't animate aMeshwithout implementing your own animation system.Some ideas for improvements:
Skeletonobject:Meshcan have aMaterialattached, it can have aSkeletonattached too, which is used to animate its vertices.VertexJointandVertexWeight, used for skinning.Modelprobably creates a default skeleton, but it can be changed with e.g.Model:setSkeleton.Model:animatecontinues to exist and sets joint transforms on the Model's skeleton.Should this be implemented? Meh. It's kind of a high effort task for medium-level payoff, but it does clean up the animation stuff a lot.