Potentially Visible Set?

Started by
11 comments, last by Ohforf sake 10 years, 5 months ago

So, I've been thinking about how to start a PVS implementation, and it essentially amounts to something like this:

For each base octree node/spatial grid cube . . .

For each of 6 camera view frustum directions . . .

Render each individual triangle wrapped in an occlusion query . . .

If the triangle passes, then add it to the list of "visible triangles" in that 1/6 frustum section for that octree node/spatial grid cube

Then. . . during runtime, determine which octree node/spatial grid cube the camera is in... intersect the camera frustum with the 6 view directional frustums to get (i guess) at most which 3 frustums are potentially visible, then render all triangles in the "visible triangles" lists of the frustums which are intersected . . .

Feedback appreciated, please especially post any good PVS implementation related material you may have.

Advertisement

Is this a terrain related question? If so, are you using a height map?

Not strictly "terrain" - but full world geometry. A game map/level. No heightmap.

In that case my suggestion may be less relevant...

A simple PVS could be made by logically dividing everything in the world (terrain, buildings, and all other static objects) and assigning each item a unique 3 byte ID - you then render everything from a given area and draw the 3 bytes to R, G, and B channel. Simply read back which 'colours' are rendered to obtain a PVS for each reachable location.

this sounds like an interesting concept, i could have the 'ID' be the index of individual triangles... and then instead of doing an occlusion test and render for each individual triangle, render the whole scene. . . but, then you have to read back every pixel so i'm not sure whether it would be faster than an individual test+render per triangle.

A PVS is not what you want for this type of application—it is good for indoor environments but very unsuitable for outdoor environments, especially in light of its shortcomings when dealing with dynamic objects and addition to better structures available that handle both dynamic objects and specifically terrain much much better.

Updating a PVS in real-time is not practice, so you would not be putting dynamic objects into it. Meaning only the terrain and buildings would be relevant choices, and both can be done better.

Terrain should be rendered using either GeoMipmaps or GeoClipmaps. GeoClipmaps is the fastest but takes some work to implement.

After that, the rest of the world should be subdivided into an octree or a hybrid between an octree and a quadtree (my suggestion). This will handle all the static objects besides the terrain as well as dynamic objects inside the game world. Standard frustum culling would be applied here.

Then PVS’s would only be applied to the interiors of buildings.

There is no one-fits-all solution to a game world. Each part is best served by a specific structure or algorithm.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

The PVS algorithm in the OP won't work. It's easy to imagine a case where, with the camera at he centre of cell 'A', you can't see cell 'B' at all, but with the camera near the edge of cell 'A' you can.
The chance of these errors occurring is proportional to your cell size. To be error free, you need infinitely small cells!

Most precomputed PVS systems will use the world geometry to define the empty/movable space, and then decompose these empty spaces into a set of polytopes (convex shapes). The faces that are shared between two polytopes become portals. For each "sector" (polytope), for each portal, you can then construct a frustum of the potentially visible area through that portal. You can then step into the adjacent 'sector', and recursively apply the same process, but ignoring any portals outside of this frustum, and when stepping through the next portal, you use the union of the current frustum and the new frustum (basically clipping so, when looking from sector A to B to C, you only check for what's inside the A->B frustum AND inside the B->C frustum).

darn thanks for pointing that out, i never thought of that. that's crazy, makes it sound just that much more complex

It sounds a bit simpler if you describe it with planes (instead of frustra like I did), and draw it out in 2D.

e.g. here's a top-down view of a level with one room connected to two corridors. The level has been compiled into a BSP-tree, which is binary tree (each node has two children) where each node defines a plane that splits the world in half.

Originally, Quake1 chose to use BSP trees because they allow you to quickly sort your polygons from back-to-front, so they could render without a z-buffer! However, they turned out to be pretty useful besides that, and many indoor renderers still use them.

Each of the red lines in the picture is a plane from the BSP tree. The letters are then the sectors that are formed after the world has been split by these planes.

If we want to build the PVS for sector A, first we add A to the list (A can see A wink.png), then we iterate through it's portals (planes). It's only got one portal in this example, which leads to B. We add B to the list, because it's directly connected via this portal, so it's obviously visible. Now we iterate through B's portals -- it has one to D and one to C. We check each of those portals against the planes we've already crossed -- so far we've only crossed from A into B. The portal from B to D is behind (or parallel with) the portal from A to B, so we can skip it! The portal from B to C is in front of our plane, so we add C to our visible list.

In the diagram, C has no further portals, but if it did, we'd check that they were in front of the A->B plane, and in front of the B->C plane.

t9egmmU.png

Speaking of Quake 1, it's worth noting that it also used it's PVS for reducing client/server communication (only potentially visible entities need be sent) and for visibility tests in combat. That's something you might want to consider and which could influence your choice of what technique you use for this.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement