• Advertisement
Sign in to follow this  

any idea skipping some vertices with DrawIndexedPrimitive()

This topic is 1853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


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

Share this post


Link to post
Share on other sites
Shoot them to oblivion with NaN-valued positions [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]
[url="http://www.imagebam.com/image/19d63e226597346"][img]http://thumbnails103.imagebam.com/22660/19d63e226597346.jpg[/img][/url]

Share this post


Link to post
Share on other sites
unbird,

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

And thanks to Gavin Williams for reordering indices technique.

Share this post


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

[url="http://www.imagebam.com/image/e58280226655242"][img]http://thumbnails106.imagebam.com/22666/e58280226655242.jpg[/img][/url]

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement