Wednesday, 23 March 2011

Death of Drawcalls - Birth of Cutscenes, also Flares, Checkpoints

First up, after years of spamming the site with jokes and the occaissional helpful post, I joined the hallowed ranks of the Titans, striding the earth with inflated ego and a pair of socks pushed down the front of their pants ...

... that's the GarageGames Associate program to normal folks.

Steve joins the other Associates for hor d'oeuvres at their Fortress of Perpetual GrimDark

So, on to drawcalls ... and ... oh wait ...

That's better ...

So, back to them drawcalls. I've a vague recollection of mentioning the damn things before in about a gazzillion blogs, but I'm always on the lookout for screwing every last bit of performance out of the engine. I'd been looking at my last demo and wondering if I could amalgamate more of the textures on the buildings. There's a lot of tiling going on with them ... so I decided to try a few experiments in reducing the sizes and adding more sections on to a single image. There was obviously going to be a fair bit of a loss in detail quality, especially close up - but as my work has obviously never been about heavy psuedo-realism, I figured I'd be able to live with it.

Original prop building at the top (5x 512 tileable textures), new single 1024 texture at the bottom.

And live with it I can. I still need up to 4 meshes for an enterable building (exterior, lightmapped interior, lightmapped props, and transparent windows). But for "prop" buildings I managed to get away with a single 1024 texture. I wasn't always able to get a mesh into a single drawcall, occaissionally requiring more, but over all my worst saving of drawcalls was 50% and my best 80% for enterable, lightmapped buildings. All my prop buildings had their drawcalls reduced to 1 from around 5. I also decided to cut out a lower LOD and suffer a few more polys at mid-range now that there's less drawcalls.

I'd also tried the same thing with my many road sections - but visually they really seemed to suffer in a much more noticeable way. So I decided to make a "supermesh" roadsystem which promptly truncated because I'd turned all the warnings of in Blender ...

So after splitting the new supermesh up a bit I'd added 130K polys to the scene for the loss of a poxy 31 drawcalls and no performance improvement with some dodgy shadowing along the now more open meshes ... which wasn't really win ... and promptly reversed the roads to how they were.

After seeing Brian Mayberry have lots of fun with glowsticks - I decided on more function creep and created flares for my player. I'd wanted to avoid a torch (US: flashlight) as it's a bit obvious and always availalbe in a HL2 type manner --- nice flashlight resource though CSMP. The flares are actually quite useful as some of my levels are intending to be "dark" - in fact Level 1 corridor crawl is fairly dark - and I've hidden pickups in various dark corners.

Which actually brings me to Level 1 of my Campaign - which is about done, just a bit more drawing to do for plot devices., but all the action is scripted and tested and tweaked and retested. There's 2 routes through it, it's got a nice ebb-and-flow of action, from scary melee based monsters creeping about in the dark, to intense, open firefights and back again.

My single player narrative campaign mode did throw up a few new issues. I created a checkpoint system so that a deceased player didn't have to restart at the beginning ... which would be fairly annoying as it takes a good 30 minutes to get through the level regardless of which path you take, and you can crossover between them in a few parts. My checkpoint respawning threw up another problem of finite pickups. Yes the dead Ai drop ammo, grenades, etc - but if you're already bulletless then it's kinda hard to get at a whopping great big alien tooled up to the nines with an automatic weapon from 100 units away when you have a melee ranged cricket bat. So I had all the "static" pickups respawn with the player, via a new permanent field that I added to the code (I'm still slowly chipping away at the cpp before getting around to making a full frontal assault on programming at a later date -- I did try to create a custom "thin" version of shapebase but it didn't go well).

All in all it works quite nicely, the extra ammo helps if the player is finding it tough. The player respawns into the continuing game rather than a reloaded one, so if you've killed half the bad guys at a position before being sent beyond the mortal coil yourself, you only have the remainder to get past. I've still to sort out a full "external" save system for campaign progress or restarting a game half way through.

And so on to cutscenes - or really player controllable in-game comics. There's next/back buttons so that the player can flick through triggered plot scene. These are mostly for story, my jokes, and occaisional hints/tips. The story boards and in-game comics are there to "complement" the gameplay - but there's a big old "Skip" button if the player would rather just get back to the action without flicking through them all.

Never let it be said that I ain't a sucker for dry wit ...

In other news, I added a visual indicator of the number of player lives remaining in the "random battle" mode (3 lives for each area - previously you had to read the info to know this and then keep count), and will also add this to a selectable "challenge" mode for the campaign levels. Eventually I'll figure out some sort of scoring system for all modes as well - not particularly important in campaign, but it takes on more significance in "random battles" and any possible, future co-op mode.

Anyhoo - vidya! Here's the comicbook and flares in action ...

And here's an older one without them which features a play through of the first 5 minutes of one of the routes through the level.

I've a few more things to sort out yet, a bit of GUI refaffing for various menus, and finishing off level 1, plus creating a randomized battle mode for that map. And then I'll release a new demo, probably next blog - which will be done when it's ready.