Jump to content
  • Advertisement
Sign in to follow this  
3TATUK2

Potentially Visible Set?

This topic is 2081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement

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.

Edited by mark ds

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!