17.2PreachingbyExample:TheArticulatedPlaceholderModel 297
Skinning
At this point in the process, we now know which bone affects a particular vertex
and to what extent it affects it. The only thing left to do is to actually grab the
bones’ matrices and apply them to our mesh’s vertices in order to transform the
mesh and animate it. The act of deforming a mesh to fit on a given skeleton’s
animation is called skinning. Multiple skinning techniques exist in the industry,
the most popular being linear-blend skinning [Kavan and Žára 2003] and spheri-
cal-blend skinning [Kavan and Žára 2005]. Both of the techniques have been im-
plemented with a programmable vertex shader in the demo code on the website,
but only the linear-blend skinning technique is explained in this section. Spheri-
cal-blend skinning requires some more advanced mathematics and could be the
subject of a whole gem by itself. However, keep in mind that if you can afford it,
spherical-blend skinning often provides better visual quality than does linear-
blend skinning. Again, also note that if you are already operating in a 3D devel-
opment environment, skinning techniques are almost certainly already available
and reusing them is preferable, as stated in our list of desired placeholder fea-
tures.
Linear-blend skinning is a very simple and widely popular technique that has
been in use since the Jurassic era of computer animation. While it has some visi-
ble rendering artifacts, it has proven to be a very efficient and robust technique
that adapts very well to a wide array of graphics hardware. The details given here
apply to programmable hardware but can be easily adapted for nonprogrammable
GPUs where the same work can be entirely performed on the CPU.
The idea behind linear-blend skinning is to linearly blend the transformation
matrices. This amounts to multiplying every bone’s matrix by its weight for a
given vertex and then summing the multiplied matrices together. The whole pro-
cess can be expressed with the equation
iijjj
j
wM
vv
, (17.8)
where
i
v
is the i-th untransformed vertex of the mesh in its bind pose,
i
v
is the
transformed vertex after it has been skinned to the skeleton,
is the transfor-
mation matrix of the j-th bone, and
ij
w
is the weight of bone j when applied to
vertex i. (In the case where only the n closest bones are kept, you can view all the
ij
w
as being set to zero except for the n closest ones.)
Implementing linear-blend skinning on programmable rendering hardware
remains equally straightforward and can be completely done in the vertex shader
stage of the pipeline. Before looking at the code, and to ensure that the imple-