Determining Sectors from portals

Started by
20 comments, last by DigitalBlur 17 years, 6 months ago

Zemedelec:

You know which sector each BSP leaf belongs to by walking the connectivity information like I described in an earlier post (The previous AP). Essentially, it's just a flood fill of the convex leafs produced by the BSP process. When you come across a portal, stop filling. The process will end when you have classified each leaf as being part of a sector.

DigitalBlur
Advertisement
Quote:Original post by DigitalBlur
You know which sector each BSP leaf...


Yeah, the BSP-era solution. Did you tried it?
I have troubles back when I tried to build BSP from relatively complex and non-convex environments - except the *tons* of leafs, numberic errors tend to cause nasty bugs... I guess it was just me.

Then I thought about CSG-ing all the geometry, and walking the faces, starting from a portal - a similar method, but with far less subdivisions (-> more stable) and imho faster.
Didn't implement it, however.
Interesting. I had thought of trying something like that but could never quite figure out how it would work. Could you give a more in-depth description of how you would implement it.

I tried implementing a similar algorithm to the one I described a few years back. However, it wasn't really successful. But that was due to problems in my maths/BSP code which caused it to fail on all but the most basic two room approach. Errors in the BSP itself couldn't be too much of a problem as engines have used this sort of pre-processing for years. However, I am concerned about making polygon splits which are not required for both performance & a fear of introducing floating point errors. I guess I'll have to find some time to implement it and see what happens.

There was also an old IOTD posted on flipcode (before it died :() where a guy was using a completely automated system for generating portals. In that system, his editor was CSG (like unreal rather than the quakes). When two subtract brushes intersected, a portal would be generated. I can understand how this sort of geometry would make this task easier, but there a so many good quake style editors available (with source too!). Performing sectoring on a poly soup also allows you to be editor agnostic which can only be a good thing.

Anyone else have any alternative approaches to the sector/portal problem? What about ways to reduce numberical errors or redundent splits?
DigitalBlur
Quote:Original post by DigitalBlur
Interesting. I had thought of trying something like that but could never quite figure out how it would work. Could you give a more in-depth description of how you would implement it.

Subdivide the world by itself, i.e. there shouldn't be polygons that cross each other. BV hierarchy will do the job - subdivide the world into a tree, til a N polys group together in the leaves. Do O(N^2) intersection in the leaves and keep everything indexed. After that compute adjacency, using simple hash-table, by inserting each edge indices to find neighbour faces.
Then start to choose portal faces and walk their neighbours using flood fill and creating sectors. After all portals are used as starting points OR are already walked AND there are unmarked faces - walk these faces too, then cast a ray until something marked with other value is hit.
That's it.

Quote:Original post by DigitalBlur
There was also an old IOTD posted on flipcode (before it died :() where a guy was using a completely automated system for generating portals.

Angel Popov, a neighbour of mine actually... :)
He however uses a relatively low-poly world AND he detects portals itself. Which is completely another problem imo...

There was another idea (which is faster to program and more stable).
Photon trace the triangle soup, using simple hierarchy (kd-tree) for collision with a bounding ray. Shoot from portals, mark geometry.
After some shooting, start to shoot backwards from unmarked polys to the world hoping to hit something marked... :)
Quote:Original post by Zemedelec
There was another idea (which is faster to program and more stable).
Photon trace the triangle soup, using simple hierarchy (kd-tree) for collision with a bounding ray. Shoot from portals, mark geometry.
After some shooting, start to shoot backwards from unmarked polys to the world hoping to hit something marked... :)


Cool, I like that Idea... No splitting & alot more stable. Did you come up with that idea? Or did you read a paper (if so, where can I get it?). I can't imagine that it would be as fast as using a BSP, although I'm sure it would scale alot better as the scene becomes more complex.

Essentially, the tracing is used to decide what is visible from a given point (a portal in this case). Graphics hardware uses the Z-Buffer to achieve this, I wonder if you could perform the tracing in hardware. It would certainly speed up the pre-processing! You would render the scene from the portals perspective and then use the results to figure out which polygons were visible. Very accurate & fast, now just to figure out how to check which polygons were rendered in the first place! Maybe Hardware Occlusion Queries? (Don't know much about this, so it maybe completely out of the question or even overkill).

Any thoughts?
DigitalBlur
Quote:Original post by DigitalBlur
Cool, I like that Idea... No splitting & alot more stable. Did you come up with that idea?

Sorry, no paper, come up with it myself.

Quote:Original post by DigitalBlur
Essentially, the tracing is used to decide what is visible from a given point (a portal in this case).

Yes, and if we continue this idea, we can shoot and save bouncing faces into a group. Later, if we bounce into a already grouped face, its whole group get marked. That way we can propagate much faster the connectivity (this is not visibility!) information through the world.

Quote:Original post by DigitalBlur
Graphics hardware...
Any thoughts?


Thought of that myself - one can render polygons with unique colors (like index <-> color conversion), only flat shaded, solid geometry. Get the back buffer, scan the rendered pixels for id-s of polygons. Nice and fast.
The problem here, is the placing of the camera. But since it can be fast, we can do that way the grouping - just place the camera in every point of a 3d grid, render into 6 cubemap faces the world and group all visible polygons into sectors.
If anything didn't marked - place camera in-front of those polys and render again.

Actually, this procedure can be done to compute bruteforce PVS by GPU - fast and easy (PVS cells - 3d grid blocks).
Couldn't you just walk your face array neighbor-by-neighbor using shared triangle edges until you've reached all neighbors? Whenever your "iterator" has reached a portal edge, you can look to see what next face shares an edge with your the previous face and and an edge with the portal. (Would have to be two discreet edges; the same edge would mean your looking at the two faces split by the portal.) This way you can wind your way around the portal and not worry about traversing to the wrong side of the portal.

If you have your artists design the buildings in a modelling app - (Maya, Milkshape, Blender) and manually place portal polygons (just normal faces tagged somehow) such that the model is cleanly sectioned off, the "sectorizer" shouldn't have any issues, methinks.

Seems like it should work to me... any thoughts?
Quote:Original post by spartanx
Seems like it should work to me... any thoughts?

It should work, IF the geometry has no flying edges, T-junctions, etc.
It is an odd requirement, because if one must triangulate a roof with a chimney because of the software that computes sectors...
Well, it IS an options - it just depends more on the input geometry.
Making CSG is a solution to that, but it is far from trivial.
Quote:Original post by Zemedelec
It should work, IF the geometry has no flying edges, T-junctions, etc.


Yep, your spot on Zemedelec! Infact, there was a guy over on Ogre3d which did just that for the Goole's Summer of Code. You can download the pre-processor he wrote from one of the forums. It seems to work (and at a good speed), but it imposes too many constraints of the Geometry in my opinion.

As calculating visibility information on the GPU. I really like the idea of using unique colours to identify polygons/polygon groups. I too had thought of the grouping that you mentioned. Would you really need a cube map? You could almost use techniques from Shadow mapping to skew the perspective. Resolution isn't really a problem as you just need to know that a poly is visible, not exactly how much of it is.

DigitalBlur
To avoid this tons of problems and work, I just allow the artist to assign objects to zones. it's very easy to use and to implement.
it has even a very nice advantage beyond the algorithms you suggested here, u can make portals like in Prey, you place just onesided portals and define the zone it maps to, this way you can let people go into a room without a way back.

This topic is closed to new replies.

Advertisement