25th February, 2009: Killzone 2 has just shipped on PlayStation 3 and gamers are getting their first taste of what is - for its time - the most technologically advanced console shooter on the market. After five years in the making, the final version of Guerrilla Games' epic title is finally being enjoyed by gamers - and analysed by rival game developers anxious to see its state-of-the-art engine.

At its Netherlands HQ, the game's creators await the response and the process of carrying out the post-mortem on its own title commences. This is one of the most crucial elements of the game development process, especially for a franchise like Killzone, where pre-production on the next instalment will almost certainly have kicked off already.

"We take a very good look to the feedback we get from reviews, forums, fans and other studios," Technical director Michiel van der Leeuw tells Digital Foundry.

"We always do a pretty thorough analysis and then see what people comment on a lot, to see if there are recurring patterns. When that's done, we filter the feedback and bring it back in as input points for the next game. Some of the issues that we wanted to tackle were improving controls, getting more variety into the game (gameplay, environment, characters, etc), fixing any hiccups/glitches and improving storytelling."

External feedback on the game was also combined with comments, criticisms and suggestions from Sony's own internal teams. Since the release of the original PlayStation way back in 1994, the platform holder has gradually built up one of the largest portfolios of studios in the games industry, and when you have the developers behind titles of the calibre of Uncharted, WipEout, God of War and MotorStorm to hand, their feedback can be hugely valuable.

"There's a pretty good positive competition and sense of learning from each other between the Sony studios," confirms van der Leeuw.

"We were doing a studio tour right after we finished Killzone 2 to get inspiration from other studios and we often found people in other studios tearing apart a preview copy of Killzone 2 to see how we did. Those were great opportunities for other studios to feed off us, but also for them to give feedback."

As the team began to put together the outline for the sequel, ideas and concepts for features that couldn't be implemented into Killzone 2 due to time constraints were brought back into focus.

"I think the exclusion of a few things like a complete co-op campaign, big vehicles, on-rails sections and a few others were things we felt would stretch us too thin. They've been on our wish-list to master for a long time and the time just wasn't there yet for Killzone 2," van der Leeuw explains.

But as the project began to take shape it became clear that the developers would be going hell for leather in implementing all of these features, as well as improving the base rendering tech to accommodate a new look for the series.

While still looking and feeling like a Killzone game, the new sequel saw the team moving in a new visual direction. The grunge and general "war is hell" murkiness of the last title was replaced with a much cleaner look, with design and effects that lent themselves to a more futuristic-looking game with a wider variation in the levels.

"This is largely an artistic direction, but there is some technology that played parts in it as well. There is a delicate balance in our colour pipeline, from what the artwork writes into the albedo buffer, to how it's lit and then how colour-correction deals with it," says van der Leeuw, referring to the internal lighting map that is a crucial part of Killzone's deferred rendering implementation.

"We were quite happy with the general look, but we also thought it was a bit too monochrome and it was very difficult to colour-correct properly. Together with the art director we worked on improving the algorithms that we use and improving our colour pipeline. We have specific hue controls at the end of the pipeline and preserve precision and colour better throughout."

While stablemate releases God of War III and Uncharted 2 both support (differing) implementations of high dynamic range rendering, Killzone 2 uses a 24-bit RGB framebuffer, which meant LDR lighting only. In previous presentations to the games industry, Guerrilla had discussed experiments using the Logluv colour space favoured by Naughty Dog, but the compromises in terms of blending and interpolation meant that the developer went with a refined version of its existing solution.

The existing buffers used in the deferred rendering setup were tweaked in order to give more dynamic range to the lighting and colour, or, as the developer puts it, "getting more bang for every bit in the buffer".

Thanks to rendering optimisations throughout the pipeline, the actual amounts of detail resolved in Killzone 3 were upped considerably in comparison with the existing game: texture resolution increased, environment and model detail levels went up a notch, and shader complexity increased. Other important elements in the engine also served to give the game a much cleaner appearance.

As discussed in our piece on the Killzone 3 multiplayer beta, Guerrilla went into production on the game knowing that it had the raw processing power available to create a much more ambitious sequel. Bearing in mind the technological accomplishments of Killzone 2, it's astonishing to think that the developer had around 40 per cent of the SPU processor cycles left available, and the developer got to work on making more use of the available resources.

"We've been doing a lot more stuff on SPUs this time around. One of the things we're very proud of is one that nobody sees: we're doing a full-depth rasterisation of tens of thousands of triangles in a software rasteriser on SPUs so we can do occlusion culling against it," van der Leeuw explains, revealing the process in which unnecessary polygons are removed from the equation, optimising the rendering process.

"This allows us to do much more aggressive culling, which in the end allows us to do more complex scenes and further draw distance. The work flow is also much nicer than what we had and it reduces the frame-rate spikes which were associated with the portal/occluder system we previously had."

Just how much of a boost this culling system offers is unclear, but it's a crucial component in the rendering system and a key technique in using SPU time to save on unnecessary RSX processing. Many developers have lamented about the NVIDIA chip's weaknesses when it comes to calculating geometry. This technique helps ensure that RSX isn't working on 3D elements that will simply be covered up by other elements in front that cover them entirely.

"It's difficult to quantify what it gives you exactly because you need to compare it against something," van der Leeuw says in conclusion.

"Compared to Killzone 2 I think we have 10 to 30 per cent less overdraw and primitives being wasted (so more of the stuff that we send to the RSX ends up on-screen and being drawn) but it depends on the circumstances."

One of the major changes to the game's look was the shift from the RSX's hardware-based quincunx anti-aliasing towards the MLAA tech pioneered by SCEE's Advanced Technology Group (ATG). MLAA had already proven its worth in God of War III and, latterly, LittleBigPlanet 2, and it's currently a component within the PlayStation Edge tools available to all PS3 developers.

The decision to shift was a curious one - QAA has obvious drawbacks in terms of image quality, but the results within Killzone 2 were a good match for the rest of the game's aesthetic.

However, the feeling within Guerrilla was that on balance, ATG's new tech would make the next Killzone look better, so they went with it.

"A major reason to switch was the fact that we really liked the look of MLAA. Quincunx always had a slight blurring effect on the screen and although it had its charms, it also made everything a bit murky," explains van der Leeuw.

"With MLAA everything was much crisper and textures look sharper, and if we want everything a bit softer we have depth of field, bloom and motion blur which we can tweak."

Other advantages for the switch were more technical in nature. The best graphical results we've seen on PlayStation 3 come about when RSX and Cell work together. Tasks that prove troublesome or computationally expensive for the graphics chip can be offloaded to Cell's phenomenally swift SPUs, and the precision of those effects is often superior too as the SPUs are capable of handling more complex code than a GPU's shader cores.

The NVIDIA component within the PS3 is also known for its issues with bandwidth - the physical amount of data it can push to its allocated 256MB of GDDR3 memory. Any kind multi-sampling anti-aliasing consumes a lot of bandwidth. Put simply, by turning its back on quincunx, Guerrilla would have more GPU time to spend elsewhere on making a better-looking game.

"With MLAA we reduced our load on the RSX quite a bit, we halved the size of the G-buffers and some depth/stencil re-primes between passes were no longer necessary, which gave us additional speed boosts," van der Leeuw observes.

"In the end it gave us quite a bit of RSX cycles and memory back, which we invested back into texture streaming, draw distance, texture sampling quality and - more indirectly - the variety in characters, environments and so on."

But MLAA isn't a magic bullet that gives you stunning quality edge-smoothing for nothing. Shifting anti-aliasing processing over to Cell and its SPUs means that Guerrilla has to schedule around 4-5ms per SPU and there were also bandwidth and XDR RAM implications too.

"We were already doing most of our post-process effects on the SPUs, but with MLAA moving to SPUs as well we had the entire post chain running there. We also need to store a full resolution colour buffer in XDR RAM all of sudden, so we had to take a hit there," van der Leeuw says, referring to the 2.7MB of memory the team needed to find in the main system RAM.

This may sound quite trivial, but having the entire post-process chain on SPU means that a fair amount of XDR space is being allocated to visual effects and other game data. Debug screens seen in the Killzone 2 production documentary show a considerable amount of memory being used by AI, physics and collision detection with sound, mesh data and graphics animation taking up significant amounts of the available space. Factor in that around 48MB of XDR is still occupied taking care of the PS3's base operating system and the challenges facing Guerrilla become clearer.

Of course, the developer did spend plenty of time optimising existing systems and moving over time-consuming code from the main PPU core across to the SPUs within Cell.

"Physics in Killzone 2 is done with Havok middleware and a lot of our custom work as well. We've been working closely with Havok to move more code to SPUs over time and also reduce the memory use and SPU time spent in physics," van der Leeuw explains, discussing how the middleware was optimised by moving it across from the Cell's PowerPC PPU core.

"We run Havok in parallel with a lot of graphics work on the same SPUs. It's definitely not cheap, but we do a lot of physics in quite a short time. Animation is all done with PlayStation Edge for the lower-level parts and our own code for the higher level. The Edge part is really fast, but we noticed that the high-level parts (which was still running on PPU) was becoming quite a bottleneck. At some point we'll have to move that to SPUs as well, but it'll be quite a re-factor."

It's not just about making the game looking prettier, either. One of the most important elements of Killzone was the advanced AI. Similar to Halo, the quality of the AI scales dramatically between the difficulty settings, adding to the replay factor. Here, porting over the systems onto the SPUs had a direct and dramatic effect on the gameplay. Killzone 3 plays out across a series of more intense warzones than its predecessor, with more enemies exhibiting greater levels of intelligence.

As van der Leeuw explains, "We optimised more code to run on SPUs so we could do more AI and bigger battles, but the focus was really on the behaviours this time. We've spent a lot of time making them more diverse and recognisable for different enemy types, as well as improving their overall quality so they're more responsive, their animations look better, they're good in close combat and brutal melee and they're just more fun to play with."

While Killzone 2 only used around 60 per cent of the available SPU cycles, the sequel sees Guerrilla tightening up its code and transferring systems across to the satellite processors, to the point where they are approaching capacity. Going forward, optimisation and rewrites of key systems would be required to free up more processing time.

Michiel van der Leeuw reckons that the Guerrilla team is now pretty au fait with the complexities of SPU coding. "By the end of Killzone 2, we had a lot of people on the team who were pretty comfortable with it, so it was just a natural progression for us to continue using it. We got to the point where they were all full though, so we had to optimise our SPU code quite a bit to fit it all in at the end."

One of the key objectives with Killzone 3 was to make the game a more social experience and this issue was tackled on two fronts. First of all, the multiplayer mode via PSN was radically upgraded with a whole new set of infrastructure, and while the game is already receiving plaudits for its online gameplay, it looks as though Guerrilla will be gradually improving the experience over time based on the new tech it has in place.

"A lot of the network code was scratched and re-written from the ground up. For us community is one of the most important aspects of multiplayer and although we were quite happy with Killzone 2's feature set we felt our networking systems wouldn't scale with what we wanted to do in future," says van der Leeuw.

"It's too bad that you don't get street credit for re-inventing yourselves, but we've got a much more flexible system now which is much more stable, responsive, gives us richer stats and provides a solid foundation for things to come."

Secondly, Guerrilla implemented a split-screen two-player mode into the game, a considerable achievement bearing in mind that the core Killzone 2 technology was never designed with this feature in mind. Presumably for streaming purposes, players are kept within the same areas of the map (with catch-up in play should one player progress too far without his partner), but the technological challenges are still significant - two completely independent views, with two entirely separate rendering passes.

While fill-rate issues aren't especially an issue here, geometry still needs to be processed twice - a process Guerrilla solved with techniques including optimised LOD (level of detail) management. But simply getting the game logic in the single-player mode to accommodate multiple players is an achievement in itself, and Michiel van der Leeuw is keen to point out that the entire single-player campaign is replicated in co-op mode; there are no developer-side cheats, shortcuts or omissions in place.

There are limits to the implementation, however. Whereas some FPS titles could support a full co-op campaign featuring online play, the Killzone co-op experience is split-screen only, with no PSN integration. Michiel van der Leeuw explains the reasoning behind this decision:

"Doing it on PSN as well would tricky because - like doing a 'normal' multiplayer game - game state needs to be synced over the network and in case of packet loss or other issues, things need to be arbitrated and made robust so nobody can get stuck, or cheat," he says.

"Because we do the entire campaign in co-op, that means that all of our game code, even the one-offs, the end-bosses, they all need to be coded with network conditions in mind. We worried that taking on too much might distract us from delivering a solid offline co-op experience, so we decided to focus on that for Killzone 3."

Part of that solid experience entailed creating a seamless gameplay experience - or as close to it as possible. Loading times were identified by Guerrilla as detrimental to the overall product (describing them as "very jarring and disruptive") so the team used techniques similar to those seen in Uncharted and God of War III to overcome the issue. Pre-rendered cinematics stored on the Blu-ray disc are played while the next level is loading in the background.

For the sake of consistency with the in-game visuals, the FMVs in Killzone 3 are generated entirely by the engine, rendered offline, then encoded using the Bink compressor.

"We could have cheated and oversampled them or do something else to make them look fancy, but it would defeat the purpose - people would notice and it'd drag them out of the game," adds Michiel van der Leeuw. But why choose Bink as the codec of choice bearing in mind its sub-optimal performance in so many games?

"Because we have the entire game streaming in data while we're showing the movies, we have to be very light on CPU usage and we have only very little memory to spare. Often games play movies when there are no game assets loaded, we play movies when all of the assets are loaded," he says.

"The more popular h.264 profiles require large buffer sizes, to deal with VBR or for reference frames. To use h.264 we'd have to drop down to a simpler profile and probably write a player which is optimised for our particular use, instead of quality and speed. In the end, Bink fares pretty well compared to other codecs when they're starved on memory and it was easy for us to integrate."

The use of these cinematics pushes the amount of space required for the game from around 13GB up towards the 25GB limit of a single-layer Blu-ray disc. However, the final game is a few megabytes short of a colossal 42GB - and that's all down to the support for full stereoscopic 3D. Every single cinematic is actually being rendered and encoded into Bink twice - first in 2D, then in 3D.

The Guerrilla Games team got to see some early 3DTV displays relatively early on during the production of Killzone 3 and were very enthusiastic about the potential.

"We got light of some 3D research going on and got to play with some prototype hardware which really impressed us. We got offered the opportunity to do it, played with the numbers a bit and then decided to go for it. We're always up for a challenge and this all seemed very promising," van der Leeuw recalls, after initially thinking that implementing 3D into Killzone would be "madness".

"Our basic technical approach for 3D was building on the work we did for split-screen. We knew we were going to have to run the renderer twice for two players looking in completely different directions with no coherency between them. We must be able to use that technology and optimise it to pieces if we have two eyes looking in the same direction, right?"

Of all the console first-person shooters out there, Killzone has always tried to be the most immersive. Killzone 2's look, and crucially its feel, was all about the sensation of making the player feel like a real person in the middle of an unimaginably dangerous battlezone - the perfect scenario for 3D. Not only that, the range of locations being planned for the sequel would also benefit immeasurably from the 3D treatment.

"3D is all about immersion, feeling that you're really there, forgetting you're sitting on the couch, being on Helghan and wanting to get off the planet. There is such a difference between a vista looking out over an icy landscape on a flat screen, or in 3D where 3km viewing range feels like 3km," van der Leeuw explains.

Similar to the techniques used in Call of Duty: Black Ops, Guerrilla decided on a full 3D implementation - true stereoscopy from start to finish - in contrast to the reprojection techniques being used in the forthcoming SOCOM 4 and apparently in Crysis 2, where a single 2D image is processed via depth data into discrete images per eye.

Video: Digital Foundry analysis of Killzone 3 gunplay shows that while there is a performance penalty in rendering stereoscopic viewpoints, often the gap between 2D and 3D is relatively small.

"This allows us to pull depth separation apart much further and prevent the layered feeling other techniques have. We also get proper stereoscopic reflections to boot and we can be much more free with things like depth of field," enthuses van der Leeuw.

"The real trick of 3D is to not make it fall apart. Most people like 3D, but when something is off - your crosshair 'feels' unnaturally placed, you gun feels like it sticks through the wall, something you try to focus on stays blurry - it breaks for people. And when it breaks, it breaks the immersion."

The Killzone 3 team achieved this by scaling depth perception dynamically, sometimes with the game code in control, sometimes with the artists themselves directly manipulating the 3D cameras. This combination helped ensure that the illusion of 3D is maintained and not compromised, making it feel significantly more immersive and "real".

The 3D team at Evolution Studios in Liverpool hasn't finished its work with the new stereoscopic format - in fact, it's expanding on it. Facial motion tracking via PlayStation Eye is being used to control the view generated by the game, a process the team has termed "holographics", and, in PlayStation Move, Sony already has a remarkably flexible 3D controller.

Guerrilla is following these proceedings closely, acknowledging the raw potential of the concept but remaining coy on any future applications, merely saying that it is "always on the lookout for things which will make the experience more immersive".

In the here and now, the studio continues to support its latest game while working on other future projects, including games disassociated from the Killzone franchise. Back in 2005, the infamous Killzone 2 "target render" displayed at E3 was met with disbelief and derision from both press and gamers, but the final game actually surpassed the quality of the CG cinematic in many ways.

Bearing in mind that the team raised the bar technologically so much this generation, we were curious to discover whether Guerrilla was working on a brand new engine, or whether it would continue to refine its existing tech.

"I don't think we'll be creating a brand new engine for this generation. We're pretty close to what you can achieve in this particular direction, although there's always room for improvement," muses Michiel van der Leeuw.

"That doesn't say we can't do anything really fresh. We're going to be doing more than just Killzone in future and new ideas lead to new techniques and fresh experiences."