Ambient occlusion, new tools and level generation

So, to follow on from my last update eventually I got settled down into London and after a bit of casting around for employment I’ve settled back into a routine of mostly full-time indie game development again. I still have no income but my brilliant co-conspirator in life is supporting me with food rations and bills. As a result rather than mostly mothballing this place I really need to spruce it up instead and put out some more frequent information on my game development activities.

First up, a little spring cleaning of some badly conceived code; my hex grid. When I initially cranked out the hex grid I naively attempted to map it to a two-dimensional array by adding a little off set if the hex was in an odd row. Unfortunately this offset adding code starts to spiral crazily out of control as the algorithms get bigger as you need two paths for every branch; one if you are on an odd hex row and another if you are on an even hex row. Code was becoming unmanageable and hardly any of it could be reused. The solution, it turns out, is to envision the hex grid instead as having three dimensions or axes – one that passes through each set of parallel edges. To index it to a two-dimensional array you just pick two of these three axes and use them as them to provide your 2D indexes. Most of this wisdom and more was unearthed by reading through this treasure trove of hexagonal maths links compiled by Amit.

I still have a few more algorithms to replace as I revisit other parts of the code but so far its working wonders on my code’s comprehensibility and length.

Next up I decided to revisit Screen Space Ambient Occlusion having previously abandoned it as something too tricky to make it look nice. Luckily since my first attempt the scholars at GameDev had put together a good article and a great forum discussion on the topic. SSAO works better on more dynamic scenes than the somewhat static levels of Free Company, the main alternative would be to calculate light maps during load time (my levels are dynamically generated). So far I’m happy enough with my SSAO implementation though and it also has the advantage of being useable across projects and reacting to any more dynamic stuff that I do put into the game. How does it look? Like this:

SSAO example

The darker image being with SSAO and the lighter without. Its main role is to fill in the shadows in corners that my ambient point lighting isn’t managing to. Hopefully it helps make the level feel a bit more substantial and less artificial.

I’ve also spent some time crafting a basic model viewer app I can use to fix problems on assets by looking at them up close. The isometric viewpoint and dark lighting of the game can hide a lot of problems, which is one of the reasons I like it 🙂 however it’s even better if I manage to catch those problems in the model viewer. The model viewer looks a bit like this:

Shot of the Model Viewer App

So far it’s helped me crack a whole range of animation and texture problems in my assets and it is also proving to be a good base from which to branch off into making other useful tools and test projects.

The guiding focus of all these efforts has been in trying to algorithmically generate  levels that both look good and preferably are hardly noticeable as algorithmically generated at all. So far I’ve got as far as generating random dungeon layouts of rectangular rooms and corridors and I’m now moving on to populating those generated rooms with believable layouts of furniture and items. Finally I’ll add room and level appropriate ‘monster’ encounters and then try to tie together all the subsystems around a super system of randomly generated base level types (e.g. ‘Warehouse’, ‘Castle’, ‘Inn’) and randomly generated goals within the level.

All this is building towards a temporary rogue-like game structure where you form a group of mercenaries to tackle a never-ending series of randomly generated missions that get gradually more tricky as your group gets more powerful. I’m going to build toward releasing that before I move on to creating the high level, principally map and economy based strategy layer that forms the other main wedge of the original Free Company design. Hopefully the rogue-like structure will allow me to a) test and improve this area of the game in a rapid way by getting lots of quick battle maps in front of people as fast as possible b) be lots of fun in its own right c) allow me to build up some kind of fan base to help try to support the rest of the game.

2 responses to “Ambient occlusion, new tools and level generation

Inscribe your comments

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: