I have a problem with color picking and anti-aliasing in OpenGL. When AA is activated, the results of glReadPixels are obviously erroneous at the boundaries of objects and intersections of objects. For instance:
I put box # 28 (RGBA: 28, 0, 0, 0) next to box number 32 (RGBA: 32, 0, 0, 0). Using AA, I can get the wrong ReadPixel value (e.g. 30), where the cube and triangle overlap or the value 14 on the edge of the boxes due to the AA algorithm.
I have ~ 4,000 thousand objects that I need to select (this is a puzzle game). It is imperative to be able to select objects by shape.
I tried to disable AA using glDisable (GL_MULTISAMPLE), but it does not work with certain AA modes (I read that it depends on the implementation of AA - SS, MS, CS ..)
So how do I select a base object?
- How to temporarily disable AA?
- Using a different buffer or even rendering context?
- Any other suggestion?
source
share