Skip to main content

Long read: The beauty and drama of video games and their clouds

"It's a little bit hard to work out without knowing the altitude of that dragon..."

If you click on a link and make a purchase we may receive a small commission. Read our editorial policy.

The Making of Killzone 3

Guerrilla walks Digital Foundry through its latest technical miracle.

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."

The aim with Killzone 3 wasn't just to introduce more variety into the visual look of the game but also to reduce some of the 'murkiness' and create a cleaner, sharper game.

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.

Guerrilla has an internal tool called Autobot that measures in-game stats from positions in each level specified by the artists. This app is run a few times a day, studying the impact on performance changes to the code have made, while taking a screenshot of the area. These in-depth stats give us some idea of the workload on the CPU and graphics chip in the specific level being profiled.

"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."