Jump to content
  • Advertisement
Sign in to follow this  
yk_cadcg

[dx10] how to fast test PntInBox in VS?

This topic is 3662 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, att, i'm drawing points. if a point is out of a box, i don't draw it. The normal way is (assuming point is: int3 p. box is: {int3 low, int3 high}):
//vs
..out bool bValidVert)
{
if(p.x >= low.x && p.y >= low.y && p.z >= low.z &&
p.x < high.x && p.y < high.y && p.z < high.z)
  bValidVert = true;
else
  bValidVert = false;
}
//ps
{
  if(!bValidVert)
    discard;
}
how to faster it? thanks! **added: seems below can faster vs a little:
 bValidVert = (all(p >= low) && all(p < high));
[Edited by - yk_cadcg on June 13, 2008 11:20:48 AM]

Share this post


Link to post
Share on other sites
Advertisement
Thanks sirob,
my original vs "bValidVert = (all(p >= low) && all(p < high));" has worked, but your suggestion might be better, as below:

//vs:
bValidVert = step(p, low) * step(high, p);

//ps:
clip(bValidVert);

Share this post


Link to post
Share on other sites
The "natural" way to discard points in D3D10 would be in the geometry shader, but I don't know what performance you'd get, but I'd say it's worth trying.

Regarding which code is best, try compiling both with fxc and taking a look at the assembly code. You can also use a tool such as ATI's GPU ShaderAnalyzer.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!