Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

any idea skipping some vertices with DrawIndexedPrimitive()

4: Adsense

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   

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.

#2 Gavin Williams   Members   

974
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   Members   

8307
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   

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   Members   

8307
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   

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   GDNet+   

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