Jump to content

  • Log In with Google      Sign In   
  • Create Account


Potentially Visible Set?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 3TATUK2   Members   -  Reputation: 708

Like
0Likes
Like

Posted 03 November 2013 - 04:41 AM

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.



Sponsor:

#2 mark ds   Members   -  Reputation: 1072

Like
0Likes
Like

Posted 05 November 2013 - 01:00 PM

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



#3 3TATUK2   Members   -  Reputation: 708

Like
0Likes
Like

Posted 05 November 2013 - 01:19 PM

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



#4 mark ds   Members   -  Reputation: 1072

Like
0Likes
Like

Posted 05 November 2013 - 01:43 PM

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, 05 November 2013 - 01:44 PM.


#5 3TATUK2   Members   -  Reputation: 708

Like
0Likes
Like

Posted 05 November 2013 - 03:51 PM

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.



#6 L. Spiro   Crossbones+   -  Reputation: 12249

Like
1Likes
Like

Posted 06 November 2013 - 01:34 AM

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


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#7 Hodgman   Moderators   -  Reputation: 27677

Like
1Likes
Like

Posted 06 November 2013 - 07:17 AM

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).

#8 3TATUK2   Members   -  Reputation: 708

Like
0Likes
Like

Posted 06 November 2013 - 10:44 AM

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



#9 Hodgman   Moderators   -  Reputation: 27677

Like
2Likes
Like

Posted 06 November 2013 - 03:36 PM

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



#10 mhagain   Crossbones+   -  Reputation: 7436

Like
1Likes
Like

Posted 06 November 2013 - 05:55 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#11 3TATUK2   Members   -  Reputation: 708

Like
0Likes
Like

Posted 06 November 2013 - 10:45 PM

Okay, thank you a lot for the explanation Hodgman but it's a bit "restricted" to specifically BSP implementation... I'm having trouble trying to mentally/visually "translate" this into working for a "basic" octree/quadtree..

 

We can start with an example, as a quadtree top-down view:

 

 

t9egmmU.png

 

Could you maybe explain how this could be applied in a case such as this?

 

In your BSP example, I kind of understand how you can check whether another plane is "behind" or "in front of" a given plane, but in a quad tree... you'd have to check 4 planes for a given section, in all four directions, so wouldn't every other section technically be "visible" by this procedure?


Edited by 3TATUK2, 06 November 2013 - 10:48 PM.


#12 Hodgman   Moderators   -  Reputation: 27677

Like
1Likes
Like

Posted 07 November 2013 - 04:06 PM

If you use a finer grid in that example, and if you first determine which cells are completely empty, then it works wink.png 

Still perform the same recursive algorithm where you step through each portal into the neighboring cells (ignoring empty cells), adding the planes you've crossed to a stack as you traverse the cells. It should work just the same as in the BSP-tree example, except with BSP you can have a bit more control over where these splitting planes are placed (often the level designers / map makers can manually place these portals as well as relying on the BSP-compiler to create them automatically). To get decent results, your cells will have to be small enough so that you get some empty cells between rooms/corridors.

 

Grey cells are empty (no geometry, so don't treat them as being neighbours that you can traverse).

Starting at the green cell in the centre picture, when we step downwards from there, we add the orange line to our stack of planes. When traversing further from there, we can never step back up over that orange line, so the corner ends up functioning as an occluder.

ahgjyQy.png

In a more complex level it ends up looking like this (Starting at "A", green is visible, grey are empty cells, white are not visible for "A")

pQoKwhE.png


Edited by Hodgman, 07 November 2013 - 04:11 PM.


#13 Ohforf sake   Members   -  Reputation: 1446

Like
1Likes
Like

Posted 10 November 2013 - 09:52 AM

Grey cells are empty (no geometry, so don't treat them as being neighbours that you can traverse).


I think this only holds for "outside" cells. Otherwise you might have a floating object in a room, that the PVS compiler deems invisible because it is completely surrounded by grey cells.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS