Making it in Unreal: the mud-morphing science that powers MXGP3

MXGP3 Unreal Engine 4

“Every day is a good day for racing,” say Milestone of their next-gen motocross sim MXGP3, though most of us would probably plump for a sunny summer weekend given the choice.

Related: here are some excellent racing games for PC.

MXGP riders are different. They relish the rain that stirs their race courses into a cake mix of clotted mud and dirt. Within a couple of laps, the trails left by bike tyres are ploughed into deep furrows – and in the worst weather, entire trenches that riders half-disappear into.

All that mess is a true representation of the sport, but also – well, it’s terraforming, isn’t it? The dynamic transformation of a level before our very eyes. Let’s take a moment, then, to dig into and appreciate the expertise that goes into the brand new MXGP3 that aims to replicate the real-life sport with its constantly shifting tracks.

Sculpting with clay

MXGP3 Steam

After 20 years of tweaking and perfecting their own technology, the Italian engineers at Milestone have switched to a new engine for MXGP3.

“We actually started from scratch,” says lead programmer Gianluca Barbera. “But that meant starting from what Unreal Engine 4 already has, so it’s a good starting point.”

With one eye on their previous code and the two decades of knowledge contained therein, the devs built a new pipeline within Unreal’s editor. That groundwork means they haven’t had to rely on an array of custom tools to handle physics and terrain modification, but can instead calculate everything in-engine.

“The physics in Unreal know what the terrain is made of, and what form it’s in, moment by moment,” explains senior R&D developer Alexandre Lebertre. “When the bikes go over the landscape, they apply forces to deform the terrain in accordance with the simulation.”

Milestone’s own bike simulation systems talk to the Nvidia PhysX that underpins Unreal Engine 4, and that maths is tangible on the track. The mud is reshaped in different ways, depending on the speed of your bike and the way you ride it. Step on it in a straight line and you’ll leave a clear line in the dirt, but a messy slide will leave a wide tear in the terrain.

Once the track begins to take on a new shape, the best players use it to their advantage – exploiting new dips and ramps to gain speed. It almost resembles a hyper-realistic remix of the iOS hit Tiny Wings, in which riding the curvy contours of hilly race tracks was essential to retain momentum.

“Things needed to be configured in a way that was also enjoyable,” notes Barbera. “Because if you have the terrain create too many spikes, it’s harder to ride on it. We had to find the right compromise between good gameplay and a reliable simulation.”

But as Lebertre adds, despite the challenges involved in implementing their system for Unreal, Milestone “also managed to improve it.”

High-performance racing

MXGP3 interview

There’s another aspect of real-life motocross that presents Milestone with a technological difficulty: the sheer number of racers. Given the cozy scope of MXGP3’s tracks, It’s not unusual to see upwards of ten bikes on-screen at once. That’s the kind of busy that traditionally comes with performance problems – but the studio have their own solutions.

Each bike is an assembly of bars, handles, and custom stickers, all drawn in high-resolution. But Milestone phase out part of that detail based on the focus of the camera.

“So if your camera is targeting a bike, the bike will have full details, full customisation, and high-resolution textures,” says Lebertre. “But if you take a look at the far bikes, or the side-of-screen bikes – the ones the user won’t look at – we are lowering the details to maintain the higher performance.”

The same principle applies to animation. MXGP3’s riders have a complex animation tree that takes the fluctuating height of the terrain into account, ensuring nobody’s feet clip through the mud. But the riders in the periphery of the player’s view use a simplified data system to keep everything running smoothly.

MXGP3 Unreal Engine 4 quote

“Our final goal was, ‘Don’t do less than we have done before,’” says Barbera. “In MXGP2 there were 22 riders, and it would be easier to say, ‘Let’s have less.’ No. We should have the same, and better. We just want to push up our limits.”

In some senses, it’s difficult to appreciate Milestone’s achievements in MXGP3. In the push for verisimilitude, they’ve created a dynamically-morphing simulation that doesn’t shout about its most impressive features – certainly not in the way games on the E3 stage do. But there’s a quiet pride that surfaces in conversation with these old hands of Milan.

“I think we did a good job this time,” Lebertre allows himself. “A really good job.”

MXGP3 is out now on Steam. Unreal Engine 4 is now free.

In this sponsored series, we’re looking at how game developers are taking advantage of Unreal Engine 4 to create a new generation of PC games. With thanks to Epic Games and Milestone.