Jump to content
  • Advertisement
Sign in to follow this  
Asheh

Triangle Count and Indices Count

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
@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 this post


Link to post
Share on other sites
Quote:
Original post by eq
Indices = U * V
Triangles = (U - 1) * (V - 1) * 2


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Dom_152
There 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by eq
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.


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 this post


Link to post
Share on other sites
Quote:
Original post by Sc4Freak
Quote:
Original post by eq
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.


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!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!