I need to access data linking a pixel on the rendered image to the vertex or closest vertex in the 3D model from which it was rendered. I don’t know if this is a begginner’s question or not, but I am definetly new the openGL. Is there any support for this sort of thing?
I haven’t done this myself, but I think you’d have to do the following:
- Render the scene for feedback mode - with separate IDs per triangle (or object)
- Use gluUnproject on the pixel you’re interested in. This should give you an approximation of the 3D position of the pixel.
- Retrieve the pixel’s object ID
- Cycle through all vertices belonging to the triangle (or object), and pick the nearest.