Jump to content
  • Advertisement
Sign in to follow this  
HAM

OpenGL Selection in Direct3D.

This topic is 4975 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 curious as to some of the standard ways people implement object selection in Direct3D. I'm looking for tutorials or technical sheets (didn't find any on MSDN). I'm a little familiar with how OpenGL might do it, with the selection buffer, but honestly I'm not to knowledgable about that either. Anyway, I don't really see a built in equivalent in Direct3D. Is there one? What are some of the standard ways you can figure out what 3D object is at what pixel? Do you make a selection buffer that stores Object IDs when a pixel is written too? Or are there better ways? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
The better way is to calculate the ray your mouse projects into the 3d world and use that ray to do intersection tests with your objects.

This involves some mathematics but saves you that extra selection buffer render pass.

Try searching "pick" and "ray picking".

Share this post


Link to post
Share on other sites
Hmmm.. well let me ask another question?

I found some resources describing how to do ray picking.

But are there any good resources describing how to implement a 'selection' buffer in Direct3d?

Or how about an efficient way of reading the depth buffer as its rendered too? Or determining which pixel is being written too, while rastering objects.

I spent about the last hour looking and couldn't come up with much.

If anyone has some links, I'd find them useful.

Share this post


Link to post
Share on other sites
I believe you're referring to pixel-perfect intersection tests. It's perfect for determining which object has been clicked on, but the drawback is that you have to re-render the entire scene with each object set to a solid color. It's pretty time consuming and you wouldn't get away with it unless it's a simple scene (although faster processors are making it a better option).

There is no equivalent to the selection buffer for Direct3D that I'm aware of. As far as doing it at the rasterization level, I think you'd be making way too much trouble for yourself (if it's even possible with a ps). The easiest, fastest way is ray picking. Is there any reason you don't want to use ray picking? I mean, what is it that you are trying to do, that you need the pixel perfect level? Maybe there are better options if we know your requirements.

Good luck,
Chris

Share this post


Link to post
Share on other sites
Quote:
I believe you're referring to pixel-perfect intersection tests. It's perfect for determining which object has been clicked on, but the drawback is that you have to re-render the entire scene with each object set to a solid color. It's pretty time consuming and you wouldn't get away with it unless it's a simple scene (although faster processors are making it a better option).

There is no equivalent to the selection buffer for Direct3D that I'm aware of. As far as doing it at the rasterization level, I think you'd be making way too much trouble for yourself (if it's even possible with a ps). The easiest, fastest way is ray picking. Is there any reason you don't want to use ray picking? I mean, what is it that you are trying to do, that you need the pixel perfect level? Maybe there are better options if we know your requirements.

Good luck,
Chris


My requirements are slim. I am just learning. So this is more out of trying to compare methods.

But considering the fact that I can find MANY resources on ray picking and vitrually no resources at all for any other 'method', that should tell me something.

Thanks for the help, it is appreciated.

Share this post


Link to post
Share on other sites
I understand, it's good to know what you can do, in case you need to. I'd start off with ray picking and maybe making a pixel perfect routine just for fun. I'd stick with those for a while. :)

Chris

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!