With that in mind, I made a dual-quaternion skinning shader. In simple terms, it facilitates skeletal animation without some of the artifacts caused by linear skinning.
Supports:
- Customizable features. Skinning can be easily disabled, as can the tangent-space calculation, etc.
- Up to 3 bones/blend weights per vertex (48 total bones possible by default).
- Blended tangent-space (for effects such as tangent-space normal mapping)
- World-to-tangent space calculations, for effects such as relief mapping.

Download GMZ (10.63 MiB)
Shaders:
How to use it:
- Copy the vertex shader.
- Discard the features you don't plan to use. If you're not planning to use something that requires the surface's tangent-space, for example, then get rid of that part of the code.
- Code your fragment shader. It could be a simple passthrough shader; it could be normal-mapping, parallax mapping, etc.
- Set up the custom vertex format. If you haven't modified the way I use vertex attributes, this will be 4 4-float vectors, with component-use specified in the comments in the vertex shader.
- Set up your model. Each vertex will require the vertex's position (in the neutral pose), the indices of the bones it uses, the weights of the first 2 bones (the third is defined implicitly to force them to sum to 1), and (if you've left the shader as-is) the tangent and binormal.
- (Recommended) Freeze your buffer after setting up your model. If your animations are skeletal, you shouldn't need to modify your model very often.
- Set up the skeleton. Create 2 1-dimensional arrays, one for the real part of the dual quaternions, one for the dual part. Fill each with the appropriate quaternions. Note: Quaternions are in xyzw format, where xyz is the imaginary part.
- Pass the arrays to the uniforms u_BoneQReal and u_BoneQDual, then render.
EDIT (2013-12-14): The vertex shader is now rather full-featured. The fragment shader is not complete, but has an implementation of relief mapping. When I get the fragment shader and a full example done, I'll update the demo.
EDIT (2013-12-17): Relief-mapping bug fix. Added relief-mapping demo. Fragment shader/example still incomplete.
EDIT (2014-02-06): I'm moving on to greener pastures (C++ and SDL). I've uploaded my latest version of this project, which includes a script for setting the dual quaternions; all you need to know is how to use regular quaternions, which is very basic knowledge.
Edited by Gamer3D, 06 February 2014 - 06:31 PM.