PDA

View Full Version : Selecting/Picking and Non-Opaque Objects



Zed Gimbal
02-20-2009, 12:51 PM
Much of the OpenGL literature that I've skimmed does not seem to address whether there are special concerns with selecting/picking in a scene which contains non-opaque objects.

As I continue to further my understanding of how to handle non-opaque objects, I've learned that, in a scene containing opaque and non-opaque objects, I should render objects according to this basic sequence:

1. With the depth buffer in normal mode, draw all opaque objects in arbitrary order.
2. With the depth buffer in read-only mode, draw all non-opaque objects in the order from furthest-from-camera to closet-to-camera.

What happens when you want to draw in GL_SELECT mode?

If the only object I want to pick is the one that's behind the mouse pointer but closest to the camera, then it would seem appropriate to make every object opaque, and then draw them in arbitrary order with the depth buffer in normal mode.

If I want the full "shishkabob" of objects which are behind the mouse pointer, then what? Would I make all the objects non-opaque, and then draw them in the order from furthest-from-camera to closet-to-camera?

Thanks in advance, and apologies again for asking something which has probably been asked many, many times before.

scratt
02-20-2009, 09:02 PM
Personally, ditch picking and go with something like Ray Sphere intersection with your geometry client side. You can use gluUnProject twice, once for farz and then once for nearz, and then use the delta to give you your picking vector into the screen.

I think I read that picking is going to be deprecated in any case. But I may be wrong.

In any case it's much better to deal with this on the CPU with your geometry there than to rely on OpenGL. It's a waste of resources to do it in OpenGL IMO.