GL_SELECT with alpha texture triangle problem?

Here I have a problem about selection picking.
While drawing a primitive(triangle), the triangle has
alpha texture map, like a tree texture.

There are opacity and transparency part in the texture map.

I wish to do correct selection picking while user click on
transparency part, the selection should not be pick.

But it seems OpenGL selection behavior ignore texture state.
It return selection by whole primitive(triangle).

Am I wrong? Or anything solution to solve my problem.


It’s a good problem…but i think that you´ll only solve it making more triangles for accurating the model complexity in the same plane, of course. The number of triangles depends for realistic picking and render speed.
More solutions: any type of masks?

An easy way would be to find the 3d position of where you clicked (read the depth value from the mouse click point, then unproject mousex,mousey,depthz), then simply search your visible tris looking for the triangle the point falls on.

Yeah, picking alpha masked polygons with selection buffer isn’t easy. It would be easier if you drew you scene by giving an individual stencil value to each object, and use that for picking. If you pick faces, you’ll run out of stencil values though. One solution is to do picking in two steps, first draw the hi byte if you index and then the lo byte, combine these and you get 16 bit indice. And so on.

If you want to use the selection buffer, you must compute the barycentric coordinates of a potential triangle in the point it’s been clicked, interpolate texture coordinates yourself and make a lookup into the texture to see if that particular texel is vilible.