Sign in to follow this  
Riviera Kid

TriangleFan and IndexBuffer

Recommended Posts

Riviera Kid    142
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.

Share this post


Link to post
Share on other sites
DJHoy    378
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.

Share this post


Link to post
Share on other sites
Riviera Kid    142
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?

Share this post


Link to post
Share on other sites
AQ    175
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.

Share this post


Link to post
Share on other sites
Christoph    122
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

Share this post


Link to post
Share on other sites
DrunkenHyena    805
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.

Share this post


Link to post
Share on other sites
JohnBolton    1372
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.

Share this post


Link to post
Share on other sites
DBX    178
That's the whole problem with fans. They're pretty useless really and, ideally, should be removed.

Share this post


Link to post
Share on other sites
S1CA    1418
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.

Share this post


Link to post
Share on other sites
DrunkenHyena    805
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. :)

Share this post


Link to post
Share on other sites
Riviera Kid    142
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?

Share this post


Link to post
Share on other sites
jollyjeffers    1570
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

Share this post


Link to post
Share on other sites
AQ    175
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this