# Commits

committed b6e5dc0

Tut09: Diagrams for topology.

• Participants
• Parent commits 79e66e1

# File Documents/Illumination/Tutorial 09.xml

separate topology. How is this possible?</para>
<para>Consider a simple cube. It has 8 vertex positions. The topology between the positions
of the cube is as follows:</para>
-        <!--TODO: diagram of cube position topology.-->
+        <figure>
+            <title>Cube Position Topology</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="CubePositionTopology.svg"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
<para>The topology diagram has the 8 different positions, with each position connected to
three neighbors. The connections represent the edges of the cube faces, and the area
bounded by connections represent the faces themselves. So each face has four edges and
four positions.</para>
<para>Now consider the topology of the normals of a cube. A cube has 6 faces, each of which
has a distinct normal. The topology is a bit unorthodox:</para>
-        <!--TODO: diagram of cube normal topology. Which is 6 points, each with four tightly curved edges that point to themselves.-->
-        <para>Here, the points represent distinct normals, not positions in space. The connections
+        <figure>
+            <title>Cube Normal Topology</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="CubeNormalTopology.svg"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
+        <para>The square points represent distinct normals, not positions in space. The connections
between normals all loop back on themselves. That's because each vertex of each face
uses the same normal. While the front face and the top face share two vertex positions
in common, they share no vertex normals at all. Therefore, there is no topological
-            relation between the front normal and the top normal. Each normal is connected to
-            itself, but to nothing else.</para>
+            relation between the front normal and the top normal. Each normal value is connected to
+            itself four times, but it is connected to nothing else.</para>
<para>We have 8 positions and 6 normals. They each have a unique topology over the mesh. How
do we turn this into something we can render?</para>
<para>If we knew nothing about OpenGL, this would be simple. We simply use the topologies to
}</programlisting>
<para>The first index in each element of the list pulls from the position array, and the
second index pulls from the normal array. This list explicitly specifies the
-            relationship between faces and topology: the first face contains 4 positions, but uses
-            the same normal for all vertices. The second face shares two positions with the first,
-            but no normals.</para>
+            relationship between faces and topology: the first face (composed of two triangles)
+            contains 4 positions, but uses the same normal for all vertices. The second face shares
+            two positions with the first, but no normals.</para>
<para>This is complicated in OpenGL because of one simple reason: we only get
<emphasis>one</emphasis> index list. When we render with an index array, every
attribute array uses the same index. Therefore, what we need to do is convert the above
index list into a list of unique combinations of vertex attributes. So each pair of
indices must refer to a unique index.</para>
<para>Consider the first face. It consists of 4 unique vertices; the index pairs {1, 0} and
-            {2, 0} are repeated. Since these pairs are repeats, we can collapse them; they will
-            refer to the same index. However, the fact that each vertex uses the same normal must be
-            ignored entirely. Therefore, the final index list we use for the first face is:</para>
+            {2, 0} are repeated, since we must draw triangles. Since these pairs are repeats, we can
+            collapse them; they will refer to the same index. However, the fact that each vertex
+            uses the same normal must be ignored entirely. Therefore, the final index list we use
+            for the first face is:</para>
<programlisting language="cpp">{ 0, 1, 2, 1, 3, 2 }</programlisting>
<para>The attribute arrays for this one face contain 4 positions and 4 normals. But while
the positions are all different, the normals must all be the same value. Even though
normals for the second face are all duplicates of each other. And there are two
positions that are duplicated. Topologically speaking, our cube vertex topology looks
like the following:</para>
-        <!--TODO: Diagram of vertex topology of a cube, with 6 separate faces.-->
-        <para>Each face is entirely distinct topologically from the rest. The two triangles in each
-            face share an edge, but that is all.</para>
+        <figure>
+            <title>Full Cube Topology</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="CubeTotalTopology.svg"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
+        <para>Each face is entirely distinct topologically from the rest.</para>
<para>In the end, this gives us 24 positions and 24 normals in our arrays. There will only
-            be 6 distinct normals and 8 distinct positions in the array, but there will be 24 of
-            each. So this represents a significant increase in our data size.</para>
-        <para>Do not be too concerned about the increase in data however. A cube, or other faceted
-            object, represents the worst-case scenario for this kind of conversion. Most actual
-            meshes of smooth objects have much more interconnected topologies.</para>
+            be 6 distinct normal values and 8 distinct position values in the array, but there will
+            be 24 of each. So this represents a significant increase in our data size.</para>
+        <para>Do not be too concerned about the increase in data however. A cube, or any other
+            faceted object, represents the worst-case scenario for this kind of conversion. Most
+            actual meshes of smooth objects have much more interconnected topologies.</para>
<para>Mesh topology is something to be aware of, as is the ability to convert attribute
topologies into forms that OpenGL can directly process. Each attribute has its own
topology which affects how the index list is built. Different attributes can share the