Problem with picking and alpha test

I am having problems with picking and using alpha test.

Here is the problem:
I have an object that is a polygon that has a texture map applied to it. The texture map is RGBA, and I only want to allow picking of the alpha values greater or equal than some alpha value (e.g. 255 - full white alpha).

I can get picking to work fine, but when I enable alpha testing (+ set the alpha test func) I always get a pick registered even if I click on a region that has zero alpha.

I also tried the same example with scissoring and found that the picking does not honour the scissor rectangle.

Help?

Thanks in advance
-Sambo

If you’re using double buffers, you can try the “Object Selection Using Back Buffer” technique described in chapter 14 of the red book. So, when you need to find what the user clicked, just render to the back buffer, glReadPixels to get the RGBA of the point clicked, and ignore if alpha != 1.0 or whatever.

Does that mean that Alpha Test and Scissor do not work with picking/selecting?

Originally posted by Sambo:

Does that mean that Alpha Test and Scissor do not work with picking/selecting?

As I understand it, that’s the case. Picking/selecting using glRenderMode(GL_SELECT) operates on the primitives. I think it just applies the viewing, clipping etc. to see if the primitive appears in a particular scene. The alpha test and scissor test both operate at the fragment level, so I don’t think they will help here (as you’ve found out).

Using the back buffer like I suggested though is a possible workaround, unless you have other reasons why you can’t use it…