# Triangle Count and Indices Count

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Given U * V vertices on a flat plane. How many triangles and indices would there be? Im trying to figure out how to generate an indices list for a list of vertices. Im guessing knowing how many indices there is would be a good start! Ash

##### Share on other sites
Indices = U * V
Triangles = (U - 1) * (V - 1) * 2

##### Share on other sites
@eq - is that right? the number of indices is directly related to the number of tris. It would be number of tris * 3...For example, if the plane was 2 verts tall and 2 verts wide there would be 6 indices not 4 ( you said 2 * 2 )

EDIT - i guess it may depend....i assumed this was a triangle list

##### Share on other sites
Yes it is a triangle list does the above still apply?

##### Share on other sites
Quote:
 Original post by eqIndices = U * VTriangles = (U - 1) * (V - 1) * 2

How can the number of indices be the same as the number of U * V vertices?

##### Share on other sites
Quote:
 Original post by Maverick_24@eq - is that right? the number of indices is directly related to the number of tris. It would be number of tris * 3...For example, if the plane was 2 verts tall and 2 verts wide there would be 6 indices not 4 ( you said 2 * 2 ) EDIT - i guess it may depend....i assumed this was a triangle list

There would be 6 vertices. But 2 of them are shared so there are 4 indices (The corner vertices.)

##### Share on other sites
Quote:
 Original post by Dom_152There would be 6 vertices. But 2 of them are shared so there are 4 indices (The corner vertices.)

i dont think this is right.....a 2X2 vertex flat plane would have 6 indices and 4 verts if oyu are using a trilist

your index buffer would look somehting like this:

0,1,2,2,1,3

##### Share on other sites
I assumed (wrongfully?) that you could share the vertices, if you can't for some reason, why even bother with indices?
Anyway if you can't share ANY vertices it's a no brainer:
VertexCount = TriangleCount * 3
If you have U * V grid points there are (U - 1) * (V - 1) * 2 triangles (as stated above).
Then the actual number of vertices needed for rendering becomes:
VertexCount = (U - 1) * (V - 1) * 6

In other words a grid can be rendered with between U * V (best case) to (U - 1) * (V - 1) * 6 (worst case) vertices.
All combinations in between are valid depending on the number of vertices that could be shared between triangles.

##### Share on other sites
Quote:
 Original post by eqI assumed (wrongfully?) that you could share the vertices, if you can't for some reason, why even bother with indices?Anyway if you can't share ANY vertices it's a no brainer:VertexCount = TriangleCount * 3If you have U * V grid points there are (U - 1) * (V - 1) * 2 triangles (as stated above).Then the actual number of vertices needed for rendering becomes:VertexCount = (U - 1) * (V - 1) * 6In other words a grid can be rendered with between U * V (best case) to (U - 1) * (V - 1) * 6 (worst case) vertices.All combinations in between are valid depending on the number of vertices that could be shared between triangles.

No, there will always be 3 times as many indices as there are triangles, regardless of wether we are sharing vertices or not.

Your figures for the triangle count are correct, but the number of indices are equal to 3 * tricount.

Therefore, for a plane of U * V vertices:
There are U * V vertices (obviously)
There are (U - 1) * (V - 1) * 2 triangles
There are (U - 1) * (V - 1) * 6 indices

##### Share on other sites
Quote:
Original post by Sc4Freak
Quote:
 Original post by eqI assumed (wrongfully?) that you could share the vertices, if you can't for some reason, why even bother with indices?Anyway if you can't share ANY vertices it's a no brainer:VertexCount = TriangleCount * 3If you have U * V grid points there are (U - 1) * (V - 1) * 2 triangles (as stated above).Then the actual number of vertices needed for rendering becomes:VertexCount = (U - 1) * (V - 1) * 6In other words a grid can be rendered with between U * V (best case) to (U - 1) * (V - 1) * 6 (worst case) vertices.All combinations in between are valid depending on the number of vertices that could be shared between triangles.

No, there will always be 3 times as many indices as there are triangles, regardless of wether we are sharing vertices or not.

Your figures for the triangle count are correct, but the number of indices are equal to 3 * tricount.

Therefore, for a plane of U * V vertices:
There are U * V vertices (obviously)
There are (U - 1) * (V - 1) * 2 triangles
There are (U - 1) * (V - 1) * 6 indices

As eq said, there can be between U * V (best case) to (U - 1) * (V - 1) * 6 (worst case) vertices. The latter is the case if you can't use ANY vertex twice, that means you'd have 3 vertices for each triangle.

But in the normal case you can share vertices so you'd end up with U * V vertices. The number of indices depends on your primitive type:

Triangle lists: (U - 1) * (V - 1) * 6 indices
Triangle strips: U * 2 indices for each strip + 2 additional indices for connecting two strips with degenerated triangles. You have V - 1 strips, so you get (V - 1) * U * 2 + (V - 2) * 2 indices.

Assuming a 10 * 10 plane you'd get 9 * 9 * 6 = 486 indices for triangle lists and 9 * 10 * 2 + 8 * 2 = 196 indices for triangle strips = a saving of 290 indices!!!

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013556
×