Finding indices of visible faces / occluded faces

Is there a way I can find the indices of the faces that are currently visible to the camera?

For instance, if I have a cube (6 sides; 12 faces) like below

I would like to end up with a set of size 6, each element being the index of a visible face.

Edit:
Maybe the following example would better illustrate why I need this.

If I have a model like the spiral model below

Depending on what angle I am viewing the model from, I may end up with faces being “stacked on top of each other”.

For instance, If I view the spiral model from above, it would look something like this:

If I project the vertices of each face to the camera, I end up with multiple faces with the same projected coordinates because they are overlapping from this view.

I would like to get only the faces that are immediately visible, and ignore the rest that are “behind” them.

If i understand what you are trying to achieve, you want to flatten the geometry based on your camera position, right ?

First you need to know if the dot product of the face normal is positive or negative against your camera. So you will be able to filter which face is in front of your camera. Take care if you are using a DoubleSide material, you will need to test the clockwise of your face to determine the right sign to use for filtering the face !

Next you will need to determine which face is behind each others, using a Ray-casting or using a filter based on the depth of each face relatively to you camera, and which face is overlapping the other.

Finally, you will need to merge the flattened face.

Good luck :wink: