Vertex buffer

From TrainzOnline
Jump to: navigation, search

A vertex buffer is a component of a render chunk which stores an array of vertices. A vertex buffer in E2 is limited to 65k vertices; any mesh which is larger than this will be split into additional render chunks, each with their own vertex buffer.

Contents

Vertex Format

Each vertex in the buffer contains the coordinate (XYZ) of the vertex in 3D space along with various metadata, possibly including:

  • Texture UV coordinates.
  • Normal vector.
  • Tangent vector.
  • Animation bone weights.
  • Color.
  • etc.

Correlation with Polygons

There is no true correlation between the number of vertices and the number of polygons in a mesh. A number of approximations can be made, but these may be wildly inaccurate depending on the nature of the mesh:

  • Each polygon in the mesh is a triangle, with exactly three vertices.
  • However, the vertices may be shared between polygons. A fully contiguous triangulated mesh has three polygons sharing each vertex, resulting in an overall average of one polygon per vertex.
  • More complicated meshes might have additional polygons sharing each vertex.
  • Discontinuous meshes might have less polygons sharing each vertex.
  • Even where polygons appear to share a vertex due to their 3D shape, they may in fact be using separate vertices because the vertex metadata differs per polygon.

Large and well smoothed meshes are likely to approach the one-polygon-per-vertex average because any discontinuities in shape or metadata are likely to be in the minority.

No mesh should have more than three vertices per polygon.

Correlation with Indices

An exceedingly inefficient mesh will have one index per vertex. An efficient mesh will approach three indices per vertex. All meshes will have exactly three indices per polygon.

Impact on Performance

Vertex count is loosely correlated with polygon count, which is one of the primary concerns when optimizing for performance.

Vertex count also has a minor direct impact on performance. Given two meshes where all else is equal, the one with the lower vertex count will have better performance and is considered more efficient. Except in extreme cases, mesh efficiency is not a major performance concern.

Personal tools