1<html>
2<head>
3<title>Defining Skinning</title>
4<link rel="stylesheet" href="../css/mainpage.css" type="text/css">
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6</head>
7
8<body>
9
10<h1>Defining Skinning</h1>
11
12<h2>Overview</h2>
13<p>
14This page describes elements that define models to be skinned. This description assumes an understanding of <a href="page_overview_shape.html">Defining Model Shapes and Vertex Attribute Data</a>. For information on animation files (.cska) applied to skinning models, see the page on animation files.
15</p>
16
17<h2>Skeleton and Bind Pose Definitions</h2>
18<p>
19The hierarchical structure of bones that control skinning is called a <EM>skeleton</EM>. (It also typically called a <EM>rig</EM>. ) Skeletons consist of multiple bones. Each bone defines a hierarchical structure by specifying its own parent bone. In addition to defining a hierarchical structure, skeletons also define a default pose. This default pose is called a <EM>bind pose</EM>. The bind pose defines how the skeleton was posed for the model shape before skinning deform. When using skinning, the way in which the model is deformed by a skeleton animation is calculated based on the relative positional relationship between bones and vertices while in the bind pose.
20</p>
21<center><img src="../image/Skeleton.jpg"><p>Skeleton and Bind Pose</p></center>
22<p>
23The &lt;Bone&gt; element is used to define a single bone. This element includes the bone name, parent bone, bind pose, and flags for scaling, making calculations and so on.
24</p>
25
26<h3>XML Hierarchical Structure</h3>
27<p>
28The &lt;Skeleton&gt; element appears inside the &lt;SkeletalModel&gt; element only once. It indicates the start of the definition of &lt;Bone&gt; elements. (There is a &lt;Bones&gt; element between these tags, but this element does not have any particular function. ) Multiple &lt;Bone&gt; elements are enumerated in the same XML hierarchy.
29</p>
30
31<table>
32<tr><td>
33<pre>
34&lt;NintendoWareIntermediateFile&gt;<br>
35 &lt;GraphicsContentCtr&gt;<br>
36  &lt;Models&gt;<br>
37   &lt;SkeletalModel&gt;<br>
38    &lt;Skeleton&gt;<br>
39     &lt;Bones&gt;<br>
40      &lt;Bone&gt;<br>
41</pre>
42</td></tr>
43</table>
44
45<h2>Matrix Palette</h2>
46<p>
47Bones and nodes created with a DCC tool are defined in the &lt;Skeleton&gt; element, but sometimes only some of the bones referenced by each skinning model are included. For example, if the torso and head are created as separate models, skinning the head will affect the neck and eye bones, but will not affect arm and leg bones. In this way, only the bones required for skinning each model are defined. An array of such conversion matrices is called a <EM>matrix palette</EM>. In this example, a matrix palette for the torso and another for the head can be defined. In the intermediate format, a matrix palette is defined for each primitive (&lt;PrimitiveSetCtr&gt;) making up a shape.
48</p>
49<center><img src="../image/MatrixPalette.jpg"><p>Assigning Bones to Matrix Palettes</p></center>
50
51<h3>XML Hierarchical Structure</h3>
52<p>
53The &lt;BoneIndexTable&gt; element appears only once in the &lt;PrimitiveSetCtr&gt; element. It defines a matrix palette using an index to specify &lt;Bone&gt; elements inside the &lt;Skeleton&gt; element.
54</p>
55
56<table>
57<tr><td>
58<pre>
59&lt;NintendoWareIntermediateFile&gt;<br>
60 &lt;GraphicsContentCtr&gt;<br>
61  &lt;Models&gt;<br>
62   &lt;SkeletalModel&gt;<br>
63    &lt;Shapes&gt;<br>
64     &lt;SeparateDataShapeCtr&gt;<br>
65      &lt;PrimitiveSets&gt;<br>
66       &lt;PrimitiveSetCtr&gt;<br>
67        &lt;BoneIndexTable&gt;<br>
68         (&lt;Bone&gt; element index array)
69</pre>
70</td></tr>
71</table>
72
73<h2>Maximum Matrix Palette Size and Primitive Subdivisions</h2>
74<p>
75There is a limit on the number of matrices that can be loaded in the shader register when performing skinning using a vertex shader. This also results in a restriction on the matrix palette size as well. If the number of bones that influence a single shape exceeds this limit, you can handle it by dividing the primitive into multiple subdivisions. (A shape &lt;SeparateDataShapeCtr&gt; can include more than one primitive (PrimitiveSetCtr).)<br> <br> The calculation of the size limit for the matrix palette takes into consideration the hardware specifications (the number of uniform registers) and the vertex shader specifications (such as the number of shader registers used for non-skinning processes like lighting).<br> A description of the calculation formula has been omitted here, since it varies depending on changes in the internal implementation of the system. <br>The upper limit on matrix palette size will influence the number of <a href="cmdl__BoneIndexTable.html">&lt;BoneIndexTable&gt;</a> elements and the <a href="cmdl__SkeletalModel.html">NeededBoneCapacity element of &lt;SkeletalModel&gt;</a>.
76
77</p>
78
79
80<h2>Enable/Disable Settings for Skinning and Coordinate System for Vertex Attribute Data</h2>
81<p>
82Skinning mode settings are defined by the SkinningMode attribute in the &lt;PrimitiveSetCtr&gt; element. SmoothSkinning enables skinning, RigidSkinning results in rigid skinning, and None disables skinning. In addition, vertex attribute data vertex coordinates, normal vector, and the tangent coordinate system differ depending on the skinning mode.
83</p>
84<ul>
85<li>Skinning Disabled</li>
86Local Coordinate System
87</ul>
88<ul>
89<li>Skinning Enabled</li>
90World coordinate system for the bind pose
91</ul>
92<ul>
93<li>Rigid skinning</li>
94Local coordinate system for bones
95</ul>
96<p>
97Vertex attribute data is maintained by the shape defined by &lt;SeparateDataShapeCtr&gt; higher in the hierarchy than the primitive &lt;PrimitiveSetCtr&gt;. The coordinate system for vertex attribute data is therefore determined at the shape level. Accordingly, the skinning modes specified between primitives inside a shape must all be the same.
98</p>
99
100<h2>Referencing Bones by Vertex</h2>
101<p>
102In the skinning process, each vertex has a bone that influences it and an associated weight. Bones that influence a vertex are defined in vertex attribute data using the BoneIndex attribute. The weight is defined by the BoneWeight attribute. Each vertex can be influenced by up to four bones.
103</p>
104<p>
105The BoneIndex attribute specifies bones using an index inside the matrix palette. Skeleton bones are referenced from the bone index defined for the vertex attribute in two stages: Vertex attribute &gt; Matrix palette &gt; Skeleton bone array. The BoneWeight attribute defines the influence of each bone on a vertex as a percent.
106</p>
107<p>
108Vertex data is referenced by &lt;IndexStream&gt; in the &lt;PrimitiveSetCtr&gt; element. The BoneIndex attribute references the &lt;BoneIndexTable&gt; inside the &lt;PrimitiveSetCtr&gt; element that references that vertex data.
109</p>
110
111<h3>XML Hierarchical Structure</h3>
112<table>
113<tr><td>
114<pre>
115&lt;SeparateDataShapeCtr&gt;<br>
116  &lt;PrimitiveSets&gt;<br>
117    &lt;PrimitiveSetCtr SkinningMode=&quot;SmoothSkinning&quot;&gt;<br>
118      &lt;BoneIndexTable&gt;28 29 52 35 36 37 27 51 21 30&lt;/BoneIndexTable&gt;<br>
119	&lt;PrimitiveSetCtr SkinningMode=&quot;SmoothSkinning&quot;&gt;<br>
120          &lt;BoneIndexTable&gt;17 53 52 63 64 65 15 16 18 &lt;/BoneIndexTable&gt;<br>
121        ...<br>
122        &lt;PrimitiveSetCtr SkinningMode=&quot;SmoothSkinning&quot;&gt;<br>
123          &lt;BoneIndexTable&gt;12 8 10 11 7 20 15 21 &lt;/BoneIndexTable&gt;<br>
124        ...<br>
125	&lt;PrimitiveSetCtr SkinningMode=&quot;SmoothSkinning&quot;&gt;<br>
126          &lt;BoneIndexTable&gt;12 8 10 11 7 20 15 21 13&lt;/BoneIndexTable&gt;<br>
127        ...<br>
128  &lt;/PrimitiveSets&gt;<br>
129  &lt;VertexAttributes&gt;<br>
130    &lt;Vector3VertexStreamCtr Usage=&quot;BoneIndex&quot; VertexSize=&quot;1880&quot; Scale=&quot;1&quot; QuantizedMode=&quot;Ubyte&quot;&gt;<br>
1319 0 0<br>
1323 0 0<br>
1333 4 0<br>
1344 0 0<br>
1359 0 0<br>
136...<br>
137  &lt;/VertexAttributes&gt;<br>
138&lt;/SeparateDataShapeCtr&gt;<br>
139</pre>
140</td></tr>
141</table>