Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


any idea skipping some vertices with DrawIndexedPrimitive()


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 ccppuser   Members   -  Reputation: 107

Like
0Likes
Like

Posted 18 December 2012 - 08:37 AM

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):
┌─┬─┬─┐
│/│/│/│
├─┼─┼─┤
│/│/│/│
├─┼─┼─┤
│/│/│/│
└─┴─┴─┘

and I want to make the mesh like this:

┌─┬─┬─┐
│/│/│/│
├─┴─┼─┤
│/ │/│
│ * ├─┤
/│/│
──┴─┘


(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.

Sponsor:

#2 Gavin Williams   Members   -  Reputation: 776

Like
1Likes
Like

Posted 18 December 2012 - 01:42 PM

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 ?

#3 unbird   Crossbones+   -  Reputation: 5992

Like
2Likes
Like

Posted 18 December 2012 - 04:45 PM

Shoot them to oblivion with NaN-valued positions Posted Image
Posted Image


#4 ccppuser   Members   -  Reputation: 107

Like
0Likes
Like

Posted 18 December 2012 - 10:38 PM

unbird,

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

And thanks to Gavin Williams for reordering indices technique.

#5 unbird   Crossbones+   -  Reputation: 5992

Like
1Likes
Like

Posted 19 December 2012 - 03:52 AM

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:

Posted Image

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.

#6 ccppuser   Members   -  Reputation: 107

Like
0Likes
Like

Posted 21 December 2012 - 04:04 AM

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.



#7 Nyssa   Members   -  Reputation: 426

Like
0Likes
Like

Posted 22 December 2012 - 06:20 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS