Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify visible vertices in OpenGL

What is the most efficient way to identify the vertices that are visible from a particular viewpoint?

I have a scene composed of several 3D models. I want to attach an identifier to each vertex (ModelID, VertexID) then generate 2D images from various viewpoints and for each image generate a list of the visible vertices identifiers (essentially this is for an image processing application).

Initially I thought to perform a dot product between a vertex normal and the camera view vector to figure out if the vertex is facing the camera or not, however if the model is occluded by another object this test would not work.

Thanks in advance

like image 890
tat0 Avatar asked Nov 01 '10 21:11

tat0


1 Answers

  1. Disable all lighting/texturing
  2. Render your geometry (GL_TRIANGLES) to populate Z-buffer
  3. Render your geometry again (GL_POINTS), selecting a different RGB color for each vertex, which maps to your model/vertex IDs
  4. Read back framebuffer and scan for the colors you used earlier, mapping back to your model/vertex IDs.

Not very fast, but it should work.

like image 64
genpfault Avatar answered Nov 13 '22 11:11

genpfault