any idea skipping some vertices with DrawIndexedPrimitive()

Started by
5 comments, last by Helo7777 11 years, 4 months ago
Hi.

I'm using DirectX9.

Thanks for reading.

I want to skip some vertices drawing mesh with DrawIndexedPrimitive() func.

Original mesh (with one DrawIndexedPrimitive() call):
[font=courier new,courier,monospace]???????[/font]
[font="courier new, courier, monospace"]?/?/?/?[/font]
???????
?/?/?/?
???????
?/?/?/?
???????

and I want to make the mesh like this:

[font=courier new,courier,monospace]???????
?/?/?/?
???????
?/ ?/?
? * ???
/?/?
?????[/font]

(the vertex marked as * <- is skipped one.)

Of course it can be achived with DrawPrimitive() func, but
DrawPrimitive() is very inefficient for some reasons such that memory efficiency or many draw call.

It seems quiet difficult problem to me.
Anyone tried to do this?
It'll be appreciate for any ideas.
Advertisement
You can't just skip one of your vertices, what then are your indices pointing to if you do that ? It doesn't even make sense to me what you are trying to do. If you want to reorder your indices then you can do that. But what it looks like you are trying to do is render a quad. So that's not going to work, it's malformed geometry.

Or is that meant to be a gap where the asterisk is ? In that case, can't you edit your index buffer to remove the 4 triangles that are affected ?
Shoot them to oblivion with NaN-valued positions laugh.png
19d63e226597346.jpg
unbird,

COOL! It is magic.
It perfectly matches to my work. Thanks.

And thanks to Gavin Williams for reordering indices technique.
Ha, I knew why I put the smiley. I quickly tested this out of curiosity. Since NaNs (or Infinity) are pretty contagious, I wouldn't be surprised if some configuration (driver/hardware) did not like it.

PIX does not mind. The Debug Runtimes don't either. But look what the reference driver does:

e58280226655242.jpg

So both lines and triangles are screwed.

To be on the safe side, rather go with Gavin's version. If you got triangle lists you can even eliminate individual triangles by setting the indices to e.g. (0,0,0). Degenerate triangles don't get rasterized.

unbird,

My project is very performance-sensitive, so Gavin's version is difficult to apply.

As you said, one proper way is making one of x/y/z value of a vertex of a triangle NaN value.

In my code, NaN value is specified with std::numeric_limits<float>::signaling_NaN() func.

This is cheap and easy.

Another way is making indices of a triangle (0,0,0) or something non-triangle vertex indices.

Both method are suit to me.

I agree with unbird, I wouldn't trust using NaN values. Gavin's approach would be the way to go. It shouldn't be too performance heavy. Just create the index buffer as a dynamic buffer so the API optimizes it for frequent CPU access. And create the vertex buffer as a static buffer if that data is not going to change.

This topic is closed to new replies.

Advertisement