<p>as the question suggests I have to identify all the faces that are visible from the camera's view and do some processing with them. I have a single mesh.</p>
<p>I am thinking of giving individual faces a different colour and do a blind render. This will enable me to read the FBO. Then I have to traverse all the pixel and find the unique faces by their colour.</p>
<p>Are there any faster way?</p>

CC BY-SA 4.0
2021-05-29T20:43:04.693Z
for simple convex objects the normal vector can be used to determine visibility, just dot it with the forward vector from the view matrix
pmw1234
CC BY-SA 4.0
2021-05-31T10:51:57.500Z
actually the above trick will give you every triangle facing the camera but triangles that are completely occluded by other triangles will also be in the list.
pmw1234
CC BY-SA 4.0
2021-05-31T16:07:36.983Z
I am dealing with non convex objects
Argha Chakraborty
CC BY-SA 4.0
2021-05-31T16:12:38.330Z
This works with any object convex or not, what it won't do is give you occlusion information, so if 1 triangle completely occludes another, both will still be in the list. I should not have put convex in there. It would even work with scenes.
pmw1234
CC BY-SA 4.0
2021-05-31T16:21:06.900Z
Oh right! I need to exclude the triangles that are occluded by other triangles.
Argha Chakraborty
CC BY-SA 4.0
2021-05-31T16:39:09.393Z
Once you have a list of triangles facing the camera, take a page out stencil shadows and use extrusion to determine visibility which is greatly simplified since the triangles must be completely contained.
pmw1234
CC BY-SA 4.0
2021-05-31T16:40:30.537Z
Then wrap the whole works up in a compute shader.
pmw1234
<opengl>
List all faces of a mesh visible from the view of the camera Opengl
Argha Chakraborty
# List all faces of a mesh visible from the view of the camera Opengl

(Asked by: username_0 on 2021-05-28)

as the question suggests I have to identify all the faces that are visible from the camera's view and do some processing with them. I have a single mesh.

I am thinking of giving individual faces a different colour and do a blind render. This will enable me to read the FBO. Then I have to traverse all the pixel and find the unique faces by their colour.

Are there any faster way?

**Tags:** opengl

> **Comments:**
> **username_1**: for simple convex objects the normal vector can be used to determine visibility, just dot it with the forward vector from the view matrix  
> **username_1**: actually the above trick will give you every triangle facing the camera but triangles that are completely occluded by other triangles will also be in the list.  
> **username_0**: I am dealing with non convex objects  
> **username_1**: This works with any object convex or not, what it won't do is give you occlusion information, so if 1 triangle completely occludes another, both will still be in the list. I should not have put convex in there. It would even work with scenes.  
> **username_0**: Oh right! I need to exclude the triangles that are occluded by other triangles.  
> **username_1**: Once you have a list of triangles facing the camera, take a page out stencil shadows and use extrusion to determine visibility which is greatly simplified since the triangles must be completely contained.  
> **username_1**: Then wrap the whole works up in a compute shader.  

---

## 0 answers

