简体   繁体   English

在OpenGL中识别可见顶点

[英]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. 我有一个由几个3D模型组成的场景。 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). 我想将标识符附加到每个顶点(ModelID,VertexID),然后从各个视点生成2D图像,并为每个图像生成可见顶点标识符的列表(实际上这是用于图像处理应用程序)。

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 提前致谢

  1. Disable all lighting/texturing 禁用所有照明/纹理
  2. Render your geometry ( GL_TRIANGLES ) to populate Z-buffer 渲染几何体( GL_TRIANGLES )以填充Z缓冲区
  3. Render your geometry again ( GL_POINTS ), selecting a different RGB color for each vertex, which maps to your model/vertex IDs 再次渲染几何体( GL_POINTS ),为每个顶点选择不同的RGB颜色,映射到模型/顶点ID
  4. Read back framebuffer and scan for the colors you used earlier, mapping back to your model/vertex IDs. 回读帧缓冲并扫描您之前使用的颜色,映射回模型/顶点ID。

Not very fast, but it should work. 不是很快,但它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM