The complexity of a triangle

Triangles are mostly simple structures living simple lives. But sometimes you forget how complex they really are. A usable triangle for 3D graphics usually contains:

  • 3 3D-vectors in space
  • 3 3D-normals
  • 3 2D-texture coordinates

To optimize, you can join some data together. Then you’ll end up with a vertex. Then your triangle will look like this:

  • 3 vertices.

Where 1 vertex has:

  • 1 3D-vector
  • 1 3D-normal
  • 1 2D-texture coordinate.

There is apparent savings there. But when joining them together in a mesh, you can save big on memory (and cache). All you need to describe a mesh, is with a list of vertices and a list of indices which forms triangles.

  • List of vertices
  • List of indices

And with this, you’re free to optimize the triangle structure more easily since there are no duplicate vertices.

About Kent Fagerjord

Professional Software Developer, doing mostly C++. Connect with Kent on Twitter.
This entry was posted in design and tagged , . Bookmark the permalink.