**What is skinning?**

We can find lots of definitions for skinning. One of them is “Process of controlling deformations using a set of deformation primitives.”. Even if this sentence sums up the whole idea of skinning, I think it is a little complex to understand for beginners.

The second definition is “Process of attaching a renderable skin to a skeleton”. This is easy to understand, and imagine but, does not include whole idea of skinning.

Thus, my favourite is “Defining how geometric surface changes according to a function of the skeletal poses.”

So, yeah, skinning is a process that we have a skeleton, skin, and a function used for binding the skin meshes to the skeleton. Using skinning, we can deform/animate any objects such as virtual characters or clothes.

**Skeleton**

Skeleton is simply tree structure of joints/bones. It is a hierarchical structure, and collection of joints/bones. Using skeleton, we manipulate skin and other geometric data. We pose the skeleton at each frame of the animation, bound the skin, and render the characters, clothes, or any deforming objects.

**Joints and Bones**

Joints allow movement within the skeleton. They includes transformations which generally include rotation plus translation matrices. These matrices are used to apply the animation to the skeleton. At each frame, each related transformation matrix is applied to the joints for posing the skeleton.

Bones are generally used as a synonym for joints but, I think the best way to define bones is thinking them as the link between joints such as a joint and its parent.

Generally, we do not render joints or bones. We need them just for defining movement of the skeleton, and calculating new position of the vertices.

**Skin/Mesh and Weights**

Skin consists of 3D triangular meshes. Almost any models you see in the games or animations rendered by using these triangular meshes.

Meshes are bound to the skeleton by a set of scalars (weights). Weights indicate the amount of influence the joint has on the vertex.

**Pose and DOF**

Pose is a given set of bone transformations. Each animation frame is generated by these transformations via applying to the skeleton.

DOF stands for *degrees of freedom*. DOF simply defines a particular axis or dimension of movement within joint. Free rigid body has 6 DOFs, 3 for position, 3 for rotation.

**Basic Skinning Algorithm**

- Specify all DOF values for the skeleton
- Recursively traverse through the hierarchy to compute world matrices
- Use world matrices to deform skin
- Render

**Linear Blend Skinning (LBS)**

LBS is also known as matrix palette skinning, skeleton-subspace deformation or enveloping. It takes rest pose shape, bone transformations, and skinning weights as inputs, and animates the skeleton transforming joints, and vertices.

**Rest pose shape** contains polygon mesh. Mesh connectivity is assumed to be constant, and only vertex positions change. Rest pose vertices are shown in *R^3* or *R^4*.

**Bone transformations** include transformation matrices, and represent animation of the skeleton as mentioned above. Animations are defined by bone transformations in* R^4*.

**Skinning weights** describe the amount of influence if a joint *j* on vertex *i*. Weights are in *R*. Each weight has to be greater or equal to 0, and sum of the all weights of a joint should be equal to 1.

Each vertex in the mesh can be attached more than one joints. LBS computes deformed vertex positions by a weighted sum (Equation below) for each vertex at each frame from rest pose vertex position.

1 2 3 4 5 |
<a href="http://www.mcihanozer.com/wp-content/uploads/LBS-EQ.png"><img class="alignnone wp-image-792" src="http://www.mcihanozer.com/wp-content/uploads/LBS-EQ-300x122.png" alt="LBS-EQ" width="240" height="98" /></a> <em>v'</em> is transformed (deformed or new) vertex position (in world space), <em>v</em> is rest pose vertex position (in skin local space), <em>w</em> is weight (influence) of <em>j</em>th joint for <em>i</em>th vertex <em>T</em> is transformation matrix of <em>j</em>th joint |

*T* Transformation Matrix

*T *transformation matrix is defined as ** T = iB W** where

**is inverse binding matrix. Inverse binding matrix transforms vertex position from skin local space to joint local space.**

*iB***world matrix of the joint.**

*W*So, when we multiply rest pose vertex position (*v*) with transformation matrix (*T*), we transform vertex position first from skin local space to joint local space then, from joint local space to world space.

Transformation matrix (*T*) has to be calculated for each joint at each frame.

**Inverse Binding Matrix, World Matrix, and Local Matrix of Joints**

**Local matrix** of a joint j (* Lj*) is defined as

*where*

**Lj = TjRjSj***T*is translation matrix (do not mistake with the transformation matrix T above),

*R*is rotation matrix, and

*S*is scale matrix.

**World matrix **of a joint j is defined as ** Wj = LjWjparent** which means multiplying joint’s local matrix with its parent’s world matrix. This calculation has to be performed for each joint, at each frame. For the root joint, world matrix is equal to its local matrix (

**).**

*Wroot = Lroot***Inverse binding** matrix is defined as inverse of rest pose world matrix (* iBj = inv(W0j) *). Since inverse binding matrix will not change during the animation, it can be precomputed for each joint

*j*.

**LBS Algorithm**

- Calculate
*iB*inverse binding matrices by using rest pose world matrices (Precomputed) - Calculate
*L*local matrices - Calculate
*W*global matrices - Calculate
*T*transformation matrices - Calculate
*v′*new vertices position for each vertex using the Equation above

**Transforming Normals and Tangent Vectors**

LBS can also transform normals, and tangent vectors. Tangent vectors can be transform as vertices (using transformation matrix *T*) using the equation above with the same skinning weights. However, tangent vectors may require normalization after transformation.

For transforming normals, if we are sure that transformation matrix does not include any non-rigid transformations, we can use the same transformation matrix, and same equation. However, ideally, we should use inverse transpose of transformation matrix for transforming the normals. Also, we should upper 3×3 matrix block of transformation matrix, and normalize the normal after the transformation.

**Conclusion**

LBS is standard algorithm for skinning. It is simple, and good starting point for advance skinning methods. Results of LBS are low cost, and acceptable.

LBS blends transformation matrices linearly. Because of the rotation component, this operation can create some problems such as *collapsing elbow *and *candy-wrapper effects*.

**Dual Quaternion Skinning (DQS)**

DQS is also known as smooth skinning, and skeletal subspace deformation (SSD). DQS can solve linear interpolation of transformation matrices. DQS blends center of rotations properly by using dual quaternions. DQS uses the equation below:

1 2 |
<a href="http://www.mcihanozer.com/wp-content/uploads/DLB-EQ.png"><img class="alignnone size-medium wp-image-793" src="http://www.mcihanozer.com/wp-content/uploads/DLB-EQ-300x44.png" alt="DLB Equation" width="300" height="44" /></a> where <em>q</em>s are unit dual quaternions, <em>w</em>s are convex weights |

Dual Quaternion Blending (DLB) equation is faster than ScLERP (Dual quaternion version of SLERP), shortest path, and constant speed.

If the transformation matrices are not dual quaternions, they are needed to converted into dual quaternions. This operation should be done for every matrix at each frame.

**DQS Algorithm**

- If working with transformation matrices convert them into dual quaternions
- Find shortest path for the quaternions
- Blend them and normalize
- Do skinning calculations

DQS can only handle rigid transformations (translation, rotation). For handling non-rigid transformations (scale, shear), skinning is converted into 2 steps (non-rigid and rigid parts) with a cost.

**Conclusion**

DQS removes artifacts better; however it is costly than LBS. Especially because of the memory requirements, LBS is still the first choice for specially video games.

**References**

- CSE 169: Computer Animation course page
*SIGGRAPH Course 2014 – Skinning: Real-time Shape Deformation, Part I: Direct Skinning Methods and Deformation Primitives by Ladislav Kavan*- Geometric Skinning with Approximate Dual Quaternion Blending
- Linear Blend Skinning Course Slide by Nadine Abu Rumman
- nVIDIA Mesh Skinning Slide by Sébastien Dominé
- Geometric Skinning Slide by M. Cihan Ozer

For implementation details OpenGL: Skeletal Animation and OpenGL:Tutorials:Basic Bones System pages can be checked.