Skip to content

Multiple Animated Poses Per Model #701

Open
@bjornbytes

Description

@bjornbytes

Currently animated models only store a single copy of their vertices, and these get animated using a compute shader. This means that a single Model object can only be rendered using a single animation per frame. If you set up a different animated pose and draw the model a second time, it will use the animation from the first draw.

This is really confusing and annoying. Model:clone was recently added to alleviate this a bit, by allowing you to create lightweight copies of a Model, each with a separate set of vertices and animation state. However it's still not really acceptable to force people to manage multiple objects like this.

LÖVR should probably do the work behind the scenes to support multiple animated poses for a single Model object. It improves usability and LÖVR will probably do a better job at managing multiple mesh copies internally than Lua is able to do.

At a high level each animated pose that gets rendered during a frame would allocate and use its own dedicated set of vertices. In pathological scenarios this can start to use huge amounts of memory.

Random notes about implementation:

  • Try to separate animated data (positions, normals, tangents) from non-animated data (uv, color) and compress it as much as possible, so that these extra copies of meshes use as little memory as possible. f32x3 positions plus un10x3 normals/tangents would be 20 bytes per animated vertex. Although if UV/colors are small enough, the extra complexity may not be worth it.
  • Probably start to try to pool these animated vertices globally instead of per-model. This will reduce overall memory usage and might make it easier to batch the compute dispatches.
  • Culling information could be used to skip animation (and therefore vertex allocation) for models that aren't visible. However, culling information isn't reliable for animated models because animation changes the bounding box.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions