Graphics‎ > ‎3D‎ > ‎


Mesh rendering is made up of vertices that are connected to form primitives that is drawn. Both the vertices and the primiteves can have attributes that modify how things are drawn. The most common primitive used is triangles.

A vertex is composed of attributes that are then interpolated over any primitive that use it. The only one that is almost always needed is position. What data one need to send in depends on the shader or settings on use for the primitive.
  • Position
  • Normal
  • Color
  • TexCoo
Arrays or Stuctures
There are two common ways to feed the attributes to a graphic API. The first is to have one array for each form of attribute. The second is to have all the attributes of a vertex in a structure and have an array of these structures. Most of the time the same functions are used to map the attributes for the API but in the second case one use a stride parameters to skip over the unrelated data for the current attribute.

Pre Transform Cache
This cache stores the untransformed vertex attributes read from memory. This will be more efficiently used when a structure system is used to feed the attribute data.

Non-indexed or Indexed
A non-indexed mesh use the vertices in the order they appear in the buffers to form primitives. A indexed mesh use reads a value from a index buffer first. Then it use that index to get the vertex from the vertex buffer. That way a vertex can be reused for more then one primitive and cut down on the amount of vertex data that is needed.

Primitive restart
Indexed rendering can use primitive restart. That is a special index that is not used to select a vertex but rather to start a new primitive with the next index. That way one can use more then one polygon or triangle strip in the same draw call. A common value for primitive restart is the max value of the integer used as index or it can be a custom value that is set using the graphic API.

Post Transform Cache
On GPU's there is a small memory buffer that keep the latest vertex shader transformed vertices. If the same vertex i used again the GPU can avoid doing the transform and use the cached content. The check to see if it is the same vertex is done by using the vertex index so this only works in indexed mode.


There are five groups of primitves used with mesh rendering. They are points, lines, triangles, quads and polygons.

Each vertex in the vertex stream is a point. Each point is drawn as a screen-aligned square that can be given a texture. The size of the square can be set for all the points or for each in the vertex shader.

Two vertex are us in a pair to form a line.

Line Strip
All the vertices form a single line with n-1 segments.

Line Loop
All the vertices form a line loop with n segments.

Every three vertices form a triangle.

Triangle Fan
Every group of 2 adjecent vertices beoynd the first will form a triangle with the first one.

Triangle Strip
Every group of 3 adjacent vertices form a triangle.


Each four vertex are used to form a quad.

Quad Strip
Each quad beyond the first use two vertex from the last quad.