PDA

View Full Version : Triangles or strips? Vertex array/VBO



Sarah22
03-15-2010, 10:31 AM
I'm reading a book about terrains a while ago and the author of that book said that I should use strips when using vertex arrays. On my engine right now i'm using triangles only and not the triangle strips because most of the people in gamedev.net told me few years ago that triangles is better than strips.

My question is which is more efficient between the two? I don't know which one to believe.

Thank you very much
Sarah

pjcozzi
03-15-2010, 11:58 AM
On today's hardware, you want to use indexed triangle lists for the vast majority of meshes. The reason is the indices and vertices can be reorganized to take advantage of the GPU's post-vertex and pre-vertex caches. See Linear-Speed Vertex Cache Optimisation (http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html) for starters.

With that said, some meshes, likes those for a wall, will have little vertex reuse so using triangle strips will save some memory because the index data is not needed.

Regards,
Patrick

dorbie
03-15-2010, 12:45 PM
Triangles only work well for drawelements due to indexed vertex caching and then only if you revisit the shared vertices of recently used triangles. i.e. you need to exploit the cache by optimizing the order you draw triangles in. I could see that you have fewer constraints when issuing triangles (compared to strips) when trying to optimize for cache but it may be about the same and it's not as generally fast.

When using drawarrays you MUST use triangle strips at a minimum or you take a 3X hit because there is no caching.

It may still be a wash using strips vs triangles with indexing in drawelements but it'd difficult to generalize. You'll save on indexes and YMMV depending on hardware.

It also depends HEAVILY on how you optimize the drawing sequence of teh triangles.

I'd still recommend supporting indexed strips with drawelements (or ranged equivalent).

Sarah22
03-28-2010, 06:08 AM
So using triangle strip and index data is the best and efficient way in Terrain with quadtrees?