So, enough excuses, on with the update!
(xvid codec required)
The first half of the video shows the latest version of the Subversion city generator. It now operates in a very different (and much better) way. Once the road network has been finished, a new system takes over – which I’ve called the Geometry Generator. This system is responsible for running all the different procedural generation algorithms in turn as they are required, generating all of the data of the city and pushing it onto the graphics card in realtime before your eyes, starting with a road network and ending at the buildings and skyscrapers.
Some technical details for those interested: This system operates on a hierarchical data structure that represents all the 3d geometry in the world. It searches that data structure, looking for “stub” nodes that haven’t yet been generated. Lets say it finds a node of type “Park” with an outline, and nothing else. It then searches a database of generation rules, looking for anything that can help it generate a park node. Once it finds one it will run that generator and add more detail into the park – such as trees, a lake, a few paths, etc. Those objects then become new child nodes in the hierarchical data structure, and can be generated in more detail later if the rules exist and if you want that much detail. So you could write all the generation rules for Park/Lake/Path/IcecreamVendor/Swings/Slide/Bins etc, going into stupid levels of detail, and the GeometryGenerator would just take care of it for you. You can generate higher levels of detail for objects near the camera, and throw away unnecessary high detail a long way away. This system can be extended easily – if I decide that streets are suddenly vital to Subversion, I can write generators for Street, Road, Pavement etc and add more detail to those previously empty nodes – streetlamps, bins, chairs etc.
One thing I’ve found : you can generate data at an astonishing rate. This system can generate data at a max of around 10,000 polygons per second (its half that in the vid because fraps is very cpu hungry), but it’s not particularly optimised at the moment. In a couple of minutes this system can build a city with over a million polygons. The previous city generator from a year ago couldn’t do anything like this. Firstly I was using openGL display lists, which wouldn’t even be able to render 1M polygons at a decent frame rate, never mind have generation occurring at the same time. I’m now using Vertex Arrays, or Vertex Buffer Objects if your gfx hardware supports it, which are an order of magnitude faster at rendering. Secondly there was no way to update display lists dynamically, but I’ve now figured out a reliable way to update Vertex Arrays with new graphics data every frame, which is why you can now see the city growing in realtime before your eyes – that’s the Geometry Generator, pushing newly generated geometry onto the graphics card in realtime. And thirdly, I’ve made the whole generation system multi-core, freeing it up from the render loop and making good use of my dual-core cpu. All three of those breakthroughs have occurred in the last six months, making this system possible.
The second half of the video shows the work-in-progress generating the insides of buildings. Right now only three bits of detail exist : support columns, elevator shafts (empty), and stairwells. But crucially, and this is where the real magic has happened : the insides of the building now use the same Geometry Generator system as the city and the same data structures, meaning the whole thing has been unified. So instead of generating Parks and Streets and Buildings, we are now generating Floors and Windows and Stairwells, but the underlying system is the same. The transitions still need a lot of work – you would be forgiven for not believing me, but you can click on any building in the city view, and the Geometry Generator will spawn that building’s shell and generate all the data inside the building dynamically. The result is that the buildings all look like they are half-finished construction sites, with just the frameworks and shells of the buildings, and none of the office details. Obviously lots more to do here.
So that’s where things are at the end of 2008. You may be wondering, what happened to the elevators and the buttons and the lua scripts and stuff? Most of that material was moved out of the project while I integrated the Geometry Generator from it’s prototype into the main codebase, and things are still a little bit untidy, but they will be coming back next. I’ve got a clear first playable in my head now, although we are a long way off still, and simulation of the insides of the building is next on the list once I’ve got some basic geometry working. I’d also like to see the transitions from City to Site handled better – ideally I’d like the Site to appear in the city view, inside the buildings you just clicked on, but we’ll see – it may be too much of a render burden, but it would look pretty cool.
- Introversion Staff
- Posts: 1168
- Joined: Sat Nov 25, 2000 7:28 pm
- Location: Cambridge, UK