Fast GL Picking (works with AutoShader)

Hey, this is great :slight_smile: ! Thank you very much for releasing this!

Glad I could help! This is the kind of community-effort that I really enjoy; someone posts an idea, an other person turns it into usable code, someone else gets inspired by it and improves upon it, and so on. And that’s why I like this place :wink: .

Well I’m not very shader-savvy, heheh, so it is definitely interesting to see how you do this. Thanks again!

On a related note:
Now if only we could come up with an equally efficient way of region-selecting multiple objects with the same kind of precision, that would be awesome. Yes, I know about this thread, but none of those solutions are ideal for object selection in editors, it seems.
I do have an idea, but it will most likely fail epically because it involves rendering every single object separately… yeah, lol.
In a nutshell, rectangular selection would go something like this:

  • create a selection camera, whose display region area is set to the selection rectangle;
  • also set the corners of the frustum to those of the rectangle and use FC_shear;
  • render each object separately (using setTagStateKey()); ( ← deal breaker )
  • check if object is in rectangle using… PNMImage.getAverageGray()!

That last step seems quite efficient, because the result of PNMImage.getAverageGray() immediately tells you whether the object is even partially inside the rectangle (color returned is anything but the clear color) or not at all.
Is there some way to get the rendering data of a particular object (from a single rendering pass) into a texture (via a shader, maybe)? Then there might still be some hope for this approach.

Anyway, sorry for going a bit off-topic.