The Making of Crysis 2 - Prima Games

The Making of Crysis 2

by Prima Games Staff

It’s been just over three weeks since Crytek released its first proper game in three years. With Crysis 2, the Frankfurt-based developer has delivered a technically excellent, graphically superb shooter that is groundbreaking in many respects. It delivers state-of-the-art visuals, effects and physics onto five-year-old console architecture, and in stark contrast to its predecessor it manages to run extremely well even on relatively middle-of-the-road PCs.

The original Crysis scaled up to challenge the future of PC hardware, a hugely rich experience that could only be savoured at its best by enthusiasts pushing their kit to the limit. In many ways it was a game that evolved in line with the advances in PC hardware. In contrast, Crysis 2 delivers a more targeted, finely honed product that somehow manages to deliver the firm’s “Maximum Game” ethos to mainstream gamers.

But why kick off with Crysis 2? With the power of CryEngine 3 at its disposal and two games’ worth of pre-existing assets and gameplay available, why not bring the original Crysis and its Warhead spin-off onto console?

“We wanted to move on to our next game and come up with a fresh setting to further develop the Crysis franchise,” explains CEO and president of Crytek, Cevat Yerli. “A port to consoles wouldn’t have been easier or cheaper necessarily and we always want to innovate and thus offer improved and refined gaming experiences.”

There is an argument that the setup of Crysis 2’s environments might have made life a little easier for console architecture, but R&D principal graphics engineer Tiago Sousa reckons that tech didn’t come into the equation. This was all about taking the game – and the developmental focus of the company – in new directions.

“It was a game design choice to move away from jungles which we have been doing for almost 10 years,” he says. “This decision was completely unrelated to any technological issues. But from a technical perspective it was a nice change to go out of our comfort zone.”

This is not to say that the migration of the franchise across from PC to multi-platform did not have a profound effect on the make-up of the game, however. There’s budget, for starters. By delivering three SKUs to the market, a project of the magnitude of Crysis 2 becomes much more viable from a financial standpoint, and the resources are there to include all the features the audience demands.

“We could not have created a game with the scope, scale, and multiplayer features of Crysis 2 if it were a PC-only title,” Sousa tells us, before going on to address accusations that the company sold out its core fanbase.

“The PC market just does not support that cost of development, but going multi-platform does. If making a game that is bigger, better, more stable, performs better across a wider range of hardware, provides a continued visual benchmark for PC gaming, and more fun with a huge single-player and multiplayer offering is considered selling out, that seems like a really odd application of the phrase. The decision to go multi-platform has allowed us to bring a better game to everyone, which has been our goal all along.”

The process of moving across to a cross-platform workflow was an immense, time-intensive task for the developer. Tiago Sousa describes it as Crytek’s “biggest challenge ever”, but the directive from Cevat Yerli was clear: no lead platform, no single-format focus. Crysis 2 had to ship simultaneously on all three systems.

The first order of business for Sousa’s team was to get the CryEngine code up and running on console in order to better appreciate the magnitude of the task facing them, so straightforward ports of all of the PC features were carried out.

“When all basic functionality was in place, it was clear that a massive amount of low-level optimisation and re-factoring would be required across the entire project,” Sousa reveals.

“The best example (or worst depending on your perspective) from the GPU performance side: the straight port of our old post-processing was taking around 30ms, and HDR post-processing took an additional 10ms. On the current CryEngine 3 iteration for both together, it is around 5ms on consoles, which is almost 10 times faster.”

Video: Crytek’s optimisation work on console led to a corresponding performance boost on PC. High setting here is roughly equivalent to the console quality. Higher-quality settings see far more computationally expensive lighting, effects plus support for NVIDIA’s FXAA.

After years of working with the state-of-the-art in terms of PC processing and graphics hardware, adjusting to the relatively decrepit consoles was not an easy task for Crytek, but on the flipside of the equation the engineering team was excited by the challenge of seeing just how much they could extract from the Xbox 360 and PlayStation 3.

“GPU side, when programmed properly, they are fairly similar. We just have to be conscious of the clear handicap on PS3 RSX in terms of vertex processing, but other than that, on fragment processing side they are relatively similar, both have their strengths but such differences become irrelevant in the long run, especially when compared to PC platforms,” Sousa says, assessing the overall experience of working with the two consoles.

“My finger-pointing at Microsoft/Sony would really be on the memory side. It’s way too low, and the biggest crippling factor from a visual perspective. I would really like to see next-gen console platforms with a minimum of 8GB.”

However, the focus on extracting as much performance as possible from the fixed architecture has seen both Sony and Microsoft develop a range of tools that allow developers to optimise their code to get the best out of the systems.

“My highest praise goes to the amazing work they did for their performance profilers, with Xbox 360 PIX and PS3’s GPAD. The PC industry has a lot to learn from such tools. I think it’s great to see NVIDIA’s NSight trying to raise the bar once again on this area. Both platforms also benefit greatly from their vast documentation and support.”

Core to the optimisation effort was the process of adjusting CryEngine to operate on a multi-core architecture. The Xbox 360 runs with six hardware threads spread across its triple-core Xenon CPU, while the PS3 only has two hardware threads on its PPU. However, it is backed by the power of its six available SPU satellite co-processors.

“If you write an engine from scratch you would establish a task pool sitting on top of five or six threads and design all parts to run as tasks. But coming from a sequentially designed engine we required an incremental approach,” explains R&D technical director Michael Glück.

“We re-factored the major parts into more and more coarse grained threads. This way it runs asynchronously and can be put onto one hardware thread on Xbox 360 right away. We then re-factored the coarse grained threads into task-based processing [and] we ported those onto SPU.”

Glück points out that while the approach for Xbox 360 was very similar to the multi-core implementation on PC, the PS3 required some special effort.

“Lots of tasks need to be spawned to run on the SPUs whereas on Xenon you have three cores each with two hardware threads. Therefore we re-factored the computational-intensive parts to run as tasks or as threads capable of spawning many tasks,” he explains.

“We also implemented special tricks like fibres to run two threads extremely efficiently on a single hardware thread. The PC gained scalability from that as well, running on quad-core is much more efficient than on a dual-core. But in the near future the engine will be even more task-orientated to scale on arbitrary core numbers.”

As regular Digital Foundry readers know, a typical approach from Sony first-party developers is to offload graphics processing tasks from the RSX onto the SPUs, effectively running Cell (or at least a percentage of its available resources) almost like a video co-processor. However, the approach with Crysis 2 is quite different, with RAM limitations being the primary issue.

“The SPUs do indeed allow for easing the workload for the RSX. We decided not to go too crazy in this direction as it requires render targets and assets to reside in main memory. We are able to run skinning for example on SPUs as well, but we could not afford the additional memory required in the end,” Glück explains.

“It is possible to use the SPUs to support deferred shading, run post-process effects and do triangle culling. But again, it all requires main memory we did not have as our levels are fairly large compared to other games and our SPUs were in fact pretty loaded with particles, animations, physics, low-level rendering and culling already.”

Video: A like-for-like performance analysis of the console versions suggests an Xbox 360 advantage, but in truth both SKUs have their respective strengths and weaknesses.

Probably the most obvious visual difference between the Xbox 360 and PlayStation 3 versions of Crysis 2 comes down to a difference in basic resolution. Neither game operates at native 720p, with each version using a different framebuffer implementation based on the strengths and weaknesses of the hardware.

“The 1152×720 resolution on 360 simply allows you to maximize eDRAM usage on a deferred lighting engine without having to resort to tiled rendering,” says Tiago Sousa.

The process of ’tiling’ the Xbox 360’s framebuffer means that the image is divided up into two or more tiles, and any geometry that bisects, say, two tiles needs to be processed twice, sapping performance. Keeping to a single tile streamlines performance.

“On the PS3, due to the extremely limited system memory we resorted to downloading memory into video memory,” Sousa continues, explaining notes left in the PS3 config files saying that the resolution downgrade saved a relatively immense 14MB of RAM.

“We bumped into severe video memory limitations, so it was a good compromise to save a big chunk of video memory for other usages. Plus, while on consoles we are CPU-bound during combat due to physics, AI, etc, on less intensive situations on the PS3 we are GPU-bound, so the additional quick 10 per cent performance gain was also very welcome.”

Sousa’s information on the make-up of Crysis 2’s processing seems to tie in quite nicely with the results of our performance analysis. We see an Xbox 360 advantage in scenarios where graphics processing is taking centre stage, but in situations where the CPU is really being stressed (for example, during combat) performance seems to hold up better on the PlayStation 3 version of the game.

However, while there are differences in the final versions on all three platforms, the commonalities are legion, and CryEngine 3 implements a range of new effects and visual techniques that weren’t available in earlier iterations of the tech. In this sense we are seeing a key technological progression from the core engine that powered the original Crysis.

“From a graphics programming perspective, firstly we switched to a gamma correct HDR rendering, which is the main reason our final lighting result looks so good on every single platform,” Sousa enthuses.

“Then the lighting system was completely revamped; there was simply no way to achieve the same results (at interactive frame-rates) with CE2, especially at HD resolutions. We can have many, many more light sources in a scene. We also introduced deferred cube map probes, meaning we can now literally have every surface with HDR reflections. This is something we never had in CE2 and finally introduced for CE3.

“Besides a lot of other significant changes, the aforementioned developments are the main reasons for an increased speed in workflow from an art developer perspective. Art doesn’t have to care much with texture/lighting/fog/etc precision issues like in old school LDR rendering engines, or spend time pre-baking lighting at all.”

Video: Really intense combat seems to put this biggest strain on the consoles, and in this case, PS3 seems to cope better.

Crysis 2’s visuals on console really are miraculous. Crytek has managed to deliver a release worthy of its heritage across three very different platforms.

“We learned a lot with the consoles, especially how to make smarter and efficient usage of scarce rendering resources. In Crysis 1 times, our attitude was, ‘oh what the heck, what’s one more additional full resolution FP16 target or a couple of full-screen passes, let’s just add it.’ You can’t take such a naive approach for consoles,” Sousa says, harking back to the ‘open spec’ he had to play with on the previous PC-only Crysis titles.

“We could have gone the easy way and simply disabled features for consoles and lower-spec machines, but this time around we wanted everyone to experience our game in the best possible way their favourite system allows. We spent a huge amount of time refactoring, optimising and balancing our rendering pipeline in order to maximise GPU performance for every system.”

The optimisations necessitated by the migration onto consoles also ensure a good experience on PC too. A base-level quad-core CPU in combination with the classic NVIDIA GeForce 8800GT – astonishingly – still manages to provide a smooth, responsive experience. While we were producing our Crysis 2 PC tech comparison, one our colleagues in Germany running with a Q6600 and Radeon HD 4850 commented that the game was actually running smoother for him than Bulletstorm.

But despite the undoubted technical achievement, not everything the developer wanted to include could make it into the final version of Crysis 2.

CryEngine 3 operates with a real-time global illumination system that provides phenomenal lighting of the environments, all calculated as the game plays as opposed to using the more traditional “pre-baked” lighting and shadowing techniques used in most games. However, despite being initially mooted for all three platforms, the shipping version of Crysis 2 didn’t implement it fully on Xbox 360 and PlayStation 3.

“Our innovative real-time GI solution was not fully complete/robust on consoles yet, it still had visible issues/artefacts which we ran out of time to address,” Sousa confirms, going on to explain that as development on Crysis 2 came to end, console resources really were being pushed to breaking point, and something had to give.

“On consoles all milliseconds and memory counts, so at end of this project we made the tough decision to disable it for consoles. We still have a very simple and coarse GI approximation on consoles, where our art department fully controls the look, meaning we pay couple of milliseconds on areas where it is actually making a significant visual contribution.”

Where the developer really was able to save a significant amount of GPU resources was in its implementation of what it calls PostMSAA, its bespoke anti-aliasing solution deployed across all three platforms. We called it a form of temporal anti-aliasing, but Crytek takes issue with that.

“If we want to be technically accurate, TAA is actually what is commonly known as motion blur. But TAA in gamer language is the naive denomination for the simplest form of amortisation of super-sampling cost: a simple linear blending between current and previous frames subsamples and which looks very similar to the old-school cheap ‘motion blur’ trick seen in many older games,” Tiago Sousa explains.

“There is no re-projection involved. At 60FPS or more, this is OK and not easily perceptible, but it’s not really useable for 30 or less FPS. PostMSAA 1.0 relies on previous frames re-projection and it’s prone to artefacts when there are un-occluded pixels, most noticeable when camera is panning fast. Although both techniques rely on amortising cost across frames, the end result and implementation is quite different.”

While traditional hardware-based multi-sampling is still used frequently, the costs in terms of memory and bandwidth, and its lack of compatibility with the increasingly common implementations of deferred rendering, are making it less attractive to developers.

However, anti-aliasing remains a key element in visual quality, so developers are frequently coming up with their own solutions. Morphological anti-aliasing is gathering pace on PS3, for example, backed by a robust implementation supplied by SCEE’s Advanced Technology Group (ATG). Crytek appraised them all before going their own way with PostMSAA.

“MLAA costs around 3.5ms on current consoles GPUs and still lacks sub-pixel accuracy like any other post processed approach. The Microsoft XDK edge blur solution is not useable at all on real world scenarios – except for a relatively graphically limited game,” assesses Tiago Sousa.

“MSAA, besides additional memory requirements, is not supported by PS3 hardware at all on alpha blended surfaces when rendering in HDR, like we do on CryEngine 3. And more globally it doesn’t support alpha-tested surfaces, without relying on ATOC, performs 0 shader anti-aliasing, plus final resolve needs to be done before tone-mapping, which leads to incorrect results in high-contrast areas.

“With PostMSAA 1.0, although this shipped version was far from perfect, all previous drawbacks are addressed and the cost was 1ms on console hardware, while on PC hardware the cost was irrelevant, in order of 0.2 ms at 1080p.”

Custom anti-aliasing technologies are in a constant state of flux, forever being retooled and improved by developers looking to increase image quality and reduce processing time. Crytek aims to improve the overall quality of PostMSAA and its competitors are surely doing the same with their own anti-aliasing implementations.

“I believe in future, for the current console hardware generation, we’ll be seeing improved hybrids of our approach, allowing subpixel accuracy, with faster post-processed techniques. NVIDIA’s FXAA 2 for example looks quite promising and from what I’ve seen, was already 2x faster than MLAA,” concludes Sousa.

CryEngine 3 is being mooted as a technology that crosses the next generation divide. Crytek says that it’s ready for the new wave of consoles that are coming in the next few years, and the firm has an exciting vision for the kinds of visuals we should be looking forward to.

“I’m a strong believer that we should already be at Avatar quality in real-time, but the mass market (not everyone has the highest end cards or CPUs for example) is significantly delaying this next step,” observes Tiago Sousa.

“The transition to a new console generation that is far less memory-bound, will allow for less painful QA/maintenance of PC assets versus console assets from an art perspective. Ideally, you want to have the same asset everywhere and not have artists making custom assets, or even levels, for specific platforms.”

But in the here and now, the developmental focus for all major games developers remains with the Xbox 360 and PlayStation 3, and Crytek believes that all the lessons it learned creating Crysis 2 will be invaluable in further refining its engine.

“I think we already tapped a large part of the consoles’ resources and hardware potential. But there is still quite some potential to push it further, especially from art side, since it was their first game with this engine iteration,” Sousa observes, suggesting that it’s not just the tools that will be improved, but also in how they are used.

“I’m quite confident they will learn to push our engine to its limits by carefully using their resources. From the tech side we will of course keep optimising and improving further, there is no such thing as the best optimisation/approach – performance and quality is always a moving target. There were also some areas we wanted to push further, for example minimising memory transfers, but we just lacked the time to make it happen.”

You may also like