# Help computing visibility in old 3d game format

I am trying to compute visibility in an old 3d file format. I am using a BSP tree have finally gotten everything built and traversable.

Now I don't have any sort of PVS, potentially visible set to work with so I need to know the most efficient way to choose what polygons to render as there are literally thousands of them. I should ideally only render the polygons that are near me and then cull the non visible ones.

Does anyone have experience with this?

-

## migrated from stackoverflow.comJun 2 '11 at 12:03

This question came from our site for professional and enthusiast programmers.

## 2 Answers

If you're looking for a way to build a PVS, I wrote a couple of articles about it at one point that you might find helpful:

http://accu.org/var/uploads/journals/overload89.pdf

http://accu.org/var/uploads/journals/overload90.pdf

The method I've described is the fairly well-known portal-based one.

An easy-to-implement alternative I saw once is to generate lots of random points in the various BSP leaves and do line of sight-testing between them -- that relies on having lots and lots of points, though, and isn't necessarily guaranteed to produce an accurate PVS.

-

Assuming your polygons should only be rendered in one of its faces (i.e. you should not render one if it's facing backwards), a "simple" approach would be:

1º Detect all polygons that are facing away from you and discard them from the rendering (use the surface normal of each polygon). Chances are that the 3D format selects the points of the polygons in such a way that the direction of the surface normal is consistent with where it is facing. This should roughly cut the number of polygons to be rendered to half.

2º Use a rendering algorithm. A "simple" one would be the Painter's algorithm.

-
wtf... 1) backface culling is done by the GPU for at least 3 decades 2) The painter's algorithm ???? First, you don't choose a "rendering algorithm", it's built-in in the GPU's silicon, and second, this is the worse you could get for OpenGL. –  Calvin1602 Jun 1 '11 at 19:04
You're right, but the poster asked for a "way to choose what polygons to render", and also that he should "ideally only render the polygons that are near me and then cull the non visible ones". This lead me to believe that his intention is to render those polygons programatically and not through hardware acceleration. He's working with an old 3D file format after all. –  Kanopus Jun 1 '11 at 22:22