Skip to main content
GameDev.net gamedev.net
🔒 Locked

TriangleFan and IndexBuffer

Started by Riviera Kid Mar 29, 2005 at 6:12 AM 11 replies 4.6k views
Original Post
Riviera Kid
Riviera Kid
I read about a LOD terrain technique which uses triangle fans. At the moment I am using TriangleLists. I was wondering how the index buffer should be arranged for a triangle fan. I cant find a tutorial mentioning it. Also, how would i "disable" a vertex when performing LOD? Thank you.
--------------------------------Dr Cox: "People are tard coated tards with ***tard filling."
DJHoy
DJHoy
Quote:
Original post by Riviera Kid
I read about a LOD terrain technique which uses triangle fans. At the moment I am using TriangleLists.

I was wondering how the index buffer should be arranged for a triangle fan. I cant find a tutorial mentioning it.

Also, how would i "disable" a vertex when performing LOD?

Thank you.


If I temember right, index 0 is at the center of the fan, and 1...N are the vertices around the edges...

As for "disabling" a vertex, you would need to maintain a "render" list seperate from your standard vertex list.
Riviera Kid
Riviera Kid
ah right, i see.

So you must have a different stream for each fan?
you cant have lots of fans in the same vertex buffer.

and i maintain a low detail index buffer and a high detail index buffer for each fan?
--------------------------------Dr Cox: "People are tard coated tards with ***tard filling."
AQ
AQ
yes .. you got that .. You need to maintain just one vertex buffer but several index buffers .. one for each resolution.

OR atleast that would be one way to do it .. I would be interested in knowing if anyone can point out some other technique.
Count your blessings before you count your problems.www.wiu.edu/users/muaiq
Christoph
Christoph
I don't recommend to use triangle fans, as this means sending many small portions of vertex data to the GPU. Try triangle strips in a vertex buffer instead - they're way faster, because you don't have to switch between them that often.
I know that Trent Polack uses fans in his article about GeoMipmapping. However, even he admits that this isn't the best solution.

Greetz, Chris
DrunkenHyena
DrunkenHyena
Triangle Fans are absolutely horrible for performance. Some algorithms naturally map to fans which is why you see them being used. Converting to indexed lists is fairly easy though.
Stay Casual,KenDrunken Hyena</FON
JohnBolton
JohnBolton
Quote:
Original post by DrunkenHyena
Triangle Fans are absolutely horrible for performance. Some algorithms naturally map to fans which is why you see them being used. Converting to indexed lists is fairly easy though.


I don't believe the fans themselves are the bottleneck, rather the problem is that only 8 or so triangles are drawn at a time when you ideally want 1000s of triangles drawn at a time.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
DBX
DBX
That's the whole problem with fans. They're pretty useless really and, ideally, should be removed.
S1CA
S1CA
Quote:
Original post by DBX
That's the whole problem with fans. They're pretty useless really and, ideally, should be removed.


Agreed, at the moment, I can [almost] no reason why you'd want to use a fan.

Though they could be fixed: have a 'special' index value that "the next vertex you fetch is the anchor/start of a new fan". But that requires hardware and/or driver support, which implies it would be on a cap like 32-bit indices are.
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
DrunkenHyena
DrunkenHyena
Quote:
Original post by JohnBolton
I don't believe the fans themselves are the bottleneck, rather the problem is that only 8 or so triangles are drawn at a time when you ideally want 1000s of triangles drawn at a time.

But since fans limit the tris you can draw at a time, then they are responsible for the poor performance. I s'pose you could say the fans are efficient themselves, but cannot be used efficiently for anything. :)
Stay Casual,KenDrunken Hyena</FON
Riviera Kid
Riviera Kid
i have been experimenting with strips instead of fans. I am getting all kinds of messed up triangles. Do i need to set a different usage or anything?
--------------------------------Dr Cox: "People are tard coated tards with ***tard filling."
jollyjeffers
jollyjeffers
Quote:
Original post by Riviera Kid
i have been experimenting with strips instead of fans. I am getting all kinds of messed up triangles. Do i need to set a different usage or anything?

You shouldn't need to change anything other than the ordering of the indicies and the D3DPT_ flag in your Draw*( ) calls...

Maybe this diagram will help:



hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
AQ
AQ
Just as you would pre-compute the fan-patterns where you omit the every second vertex, every fourth vertex and so on, precompute a triangle list or better still, tri-strip pattern and store them in your crack-patching index buffer.


That way you can use tri-strip instead of a fan. However, since this strip is not going to span more than a few edge vertices, there really is not much lost in efficiency weather you use a tri list, tristrip or a fan!

So fans are good for a start and easy to manage. Do it for a start, and then when you have got it working, maybe you wil 'see' another way to optimize them.



[Edited by - AQ on March 30, 2005 6:46:11 PM]
Count your blessings before you count your problems.www.wiu.edu/users/muaiq

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.