Sign in to follow this  
schupf

DX10: TriangleStrip restart

Recommended Posts

Hello, I tried to render a terrain with a indexed trianglestrips. My vertex grid looks like this (9 vertices):
6----7----8
|    |    |
3----4----5
|    |    |
|----|----|
0    1    2
The indices for the upper row are: 0, 3, 1, 4, 2, 5 Now I want to continue with the upper row but obviously this isnt possible. So I tried to generate a degenerated triangle to restart the strip by adding 5 a second time to the indexbuffer: 0, 3, 1, 4, 2, 5, 5 Now I continued with the upperrow: 0, 3, 1, 4, 2, 5, 5, 3, 6, 4, 7, ... But if I render the grid it looks strange so obviously there is something wrong with my "degenerated" triangle. What did I do wrong? Doesnt repeating an index restart the strip? If not: how can I continue with row 2?

Share this post


Link to post
Share on other sites
Creating a single degenerate triangle won't restart the strip. A triangle strip contains a triangle for every 3 consecutive vertices. So your triangle strip generates the triangle 5,3,6, which of course is wrong. One solution is to duplicate the first vertex of the next row as well.

Share this post


Link to post
Share on other sites
Yup, in order to restart your strip you need to duplicate the last index of the first strip and the first vertex of the second strip.

-- OR --

Insert an index with the value 0xFFFF and take advantage of this neat new feature of DirectX 10 [smile]

Also, if your terrain mesh has dimensions row x colums and rows < colums, you should try to render in colums order instead of row order so that repeating indices be as close as possible to each other, possibly taking better advantage of the post-transform vertex cache. It's just a guess, it could quite as well make no differene at all (or be worse since you'd have more "strip reatarting" and/or degenerates triangles)

JA

Share this post


Link to post
Share on other sites
Do you mean adding 0xFFFF in the indexbuffer restars the strip?

So in my case: 0, 3, 1, 4, 2, 5, 0xFFFF, 3, 6, 4, 7, ... ?
I tried that but it still doesnt work: http://www.infoboard.org/screenshots/tristrip.png

I tried to search about the 0xFFFF DX SDK Docu but I didnt find anything...

Share this post


Link to post
Share on other sites
Strange..
This is a quote from my SDK's doc (April 2007)

Quote:

ID3D10Device::CreateBuffer

...

Multiple line or triangle strips can be defined in a single index buffer. Setting an index to the maximum possible value (0xffff for a 16-bit index, 0xffffffff for a 32-bit index) indicates the end of one strip and the beginning of another strip.


Share this post


Link to post
Share on other sites
Quote:
Original post by janta
It's just a guess, it could quite as well make no differene at all (or be worse since you'd have more "strip reatarting" and/or degenerates triangles)
It'll make no apparent difference to vertex cache hit rates. If you actually want to optimize that, you'll need to use columns of short strips.

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