regl icon indicating copy to clipboard operation
regl copied to clipboard

Skeletal animation demo

Open mikolalysenko opened this issue 7 years ago • 11 comments

It would be cool to have a demonstration showing how to implement something like skeletal animation/vertex skinning on top of regl. There is a half baked version on the skeleton branch currently, but it is currently blocked by the collada parsing being incomplete. If we can fix that up, then making a demo shouldn't be too hard.

mikolalysenko avatar Aug 01 '16 17:08 mikolalysenko

Here's the issue for fixing the parser -> https://github.com/chinedufn/collada-dae-parser/issues/3

EDIT: This was not the actual issue!

chinedufn avatar Aug 04 '16 01:08 chinedufn

What was wrong

So it turns out that the issue was my ignorance of control (non-deformation) joints like IKs, pole targets, etc. It turns out that the collada format doesn't do much to support these.

The model that we were trying to use had these types of control joints, so it just didn't work when we tried to use it a few months ago.

The parser will now throw an error if you attempt to use a collada file that contains control joints. Instead, you must first bake the effects of your control joints into your deformation bones

Path Forward

We already have a reference vertex shader and fragment shader so we'd effectively be copying and pasting them into a regl program.

chinedufn avatar Jan 02 '17 13:01 chinedufn

From my experience, COLLADA is the worst possible format for loading assets because it's so insanely complicated (it's only great for exchanging assets between applications). If it's for a demo with a single hardcoded model, consider something like GLTF.

I wrote my own COLLADA loader/converter that loads a COLLADA file and exports it to a custom JSON+binary format that's super easy to parse in browsers. See this live preview and the github repo.

The live preview renders animated models, and I also have a highly experimental branch with support for animation blend trees (see below image for an example of smoothly blending between standing/walking/running animations). Feel free to have a look at any of this and scrap any usable code from it.

blendtree2 I bought the model from bitgem.com, so I can't share it

crobi avatar Jan 26 '17 11:01 crobi

I would second glTF. Here is a glTF repo with sample models

vorg avatar Jan 26 '17 11:01 vorg

@chinedufn what are your thoughts on adapting: https://github.com/chinedufn/skeletal-animation-system to use regl? I was just considering this but haven't wrapped my head around it yet.

kevzettler avatar Feb 10 '17 03:02 kevzettler

@crobi @vorg for sure for sure, wouldn't hurt to have examples for how to deal with both file formats though. But yeah just a question of where to start.


@kevzettler if you're interested in doing that I'd be happy to answer any questions / provide advice on how to get started / help in any way that I can.

chinedufn avatar Feb 10 '17 15:02 chinedufn

I ported @chinedufn 's skeletal-animation-system. To regl see:

https://github.com/chinedufn/skeletal-animation-system/pull/3

I am interested in feedback on the demo and further discussion here.

We could use that as the example. It is a good start, but I feel there is room yet for a more simplified example. The skeletal-animation-system demo has code for texture support, a camera, and dual quaternion animation joint blending. I can picture a more simplified demo with a single, untextured, animated skinned mesh.

Additionally, I feel the Blender -> collada -> regl/WebGL work flow is not the best learning example. I started it on a personal model and found the manual conversion of IK joints to deformation joints to be real tedious.

On the topic of GLTF. Khronos group is currently requesting quotations on a contract project, to build a Blender -> GLTF exporter. See: https://www.khronos.org/rfq/request-for-quote-blender-gltf-exporter . You could build out the exporter and test it against regl. It could be a good regl mindshare building opportunity.

kevzettler avatar Mar 05 '17 23:03 kevzettler

the Blender -> collada -> regl/WebGL workflow is not the best learning example

The glTF Blender exporter is now in alpha, and does support morph targets: https://github.com/KhronosGroup/glTF-Blender-Exporter/

donmccurdy avatar Jul 18 '17 13:07 donmccurdy

Does the skeleton branch mentioned in the OP still exist somewhere?

donmccurdy avatar Aug 05 '20 07:08 donmccurdy

@donmccurdy if you're looking for regl skeletal animation support I did put together a demo for the skeletal-animation-system module at: https://github.com/chinedufn/skeletal-animation-system/pull/3

I'm not sure why it was removed form the master branch of the repo but it was working with at skinned model. I currently use regl for skeletal animation in a similiar manner in an ongoing project

kevzettler avatar Aug 06 '20 03:08 kevzettler

I don't quite remember why I removed it, but I think I was planning to re-write the demo site for some reason but then I changed languages and stopped using skeletal-animation-system.

chinedufn avatar Aug 06 '20 15:08 chinedufn