Skip to main content
GameDev.net gamedev.net
🔒 Locked

Selection in Direct3D.

Started by HAM Jan 6, 2005 at 7:22 AM 5 replies 1k views
Original Post
HAM
HAM
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.
Endurion
Endurion
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".
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
HAM
HAM
Quote:



Try searching "pick" and "ray picking".



Thanks, for the reply.
HAM
HAM
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.
Supernat02
Supernat02
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
Chris ByersMicrosoft DirectX MVP - 2005
HAM
HAM
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.

Supernat02
Supernat02
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
Chris ByersMicrosoft DirectX MVP - 2005

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.