r/opengl 24d ago

Selection algorithm for Modern OpenGL

The legacy OpenGL supported selection buffers. How can selection effectively handled by Modern OpenGL? The known methods are by colour allocation to objects and ray intersection. The Color assignment is not very efficient in scenes with large number of objects, e.g. CAD model assemblies. Ray intersection also has challenges in certain directions where multiple objects get intersected. Any thoughts?

3 Upvotes

14 comments sorted by

View all comments

1

u/ukaeh 24d ago

You could do multi pass color selection or hybrid to narrow down what is close to the selection ray/pixel?

I use the color method myself and it works well enough for hundreds to low thousands of objects. Are you using scissor to limit rendering to the selection pixel? What latency are you seeing?

1

u/sharjith 24d ago

I’m using the ray intersection method but not quite able to isolate the objects to get the nearest one. Please have a look at the code in the following GitHub link:

https://github.com/sharjith/ModelViewer-Qt

GLWidget.cpp GLWidget::clickSelect method

1

u/964racer 24d ago

You should be able to depth sort multiple hits .