Kadath portal aggregation / selection working

· by Steve · Read in about 3 min · (465 Words)

I’ve had a little more time this week to get back into Kadath, and I have achieved one of the milestones I set myself - that of establishing ‘good’ portals from the many low-level portals I’d derived from the polygon soup. Here’s a couple of shots:

Now, I realise this isn’t exactly very exciting or sexy looking. “What, no per-pixel lighting?” I hear you cry - well, that’s not the point of this exercise; those screenshots subtly demonstrate some very important points:

  1. All polys in this scene are sent in as an unstructured polygon soup
  2. Convex areas are constructed from the soup and portals between them detected
  3. Green transparent polys are portals which are those which are considered ‘good’, red denotes those which are considered ‘bad’

Even though this scene is trivial (build by hand in code), all the principles apply to a scene of arbitrary complexity.

Firstly, note how all the portals taken together partition everything off into convex areas. Secondly, note that the green portal is ‘good’ because it completely splits the level off, hermetically sealing 2 complete sections of the level off from each other, whilst the other portals do not. Lastly, note that when the green ‘good’ portal is formed, it actually becomes a non-convex portal, which is allowed as a final portal by Kadath, since final cells do not have to be convex. Note also that even though the portal is coplanar with one of the faces of the cube in the middle, the portal is correctly formed around the cube, not through or over it.

So what we have here is that even though we were given a completely unstructured set of polys, we’ve turned it into a useful structure. This is extremely powerful because it means, unlike systems which are based on building levels out of ‘brushes’, which require quite specialised level creation tools, the input to Kadath can be any thing that can export polygons.

Clearly there’s much work still to be done; further cost-based analysis of the cells will eventually be done so as to merge together cells that are too ‘small’ in terms of rendering cost to justify their separate existence even after eliminating structurally unsound portals. The order of the day for rendering is to batch, batch, batch as much as possible, whilst still keeping a reasonable partitioning for culling. It’s also worth noting that even whilst batching up for rendering, Kadath keeps the lowest-level convex area structure it built early on - this will be useful for collision tests and other such things.

So, not that visually exciting perhaps, but I’m glad this much is working so far, having been disappointed over the past 2-3 months at having too many distractions to really knuckle down to it. Hopefully I can maintain the momentum.