Developer postOriginal post (opens in a new tab)

Mesh Around and Find Out

Creating believable terrain is one thing, but if we're going to skim through valleys at hundreds of knots, we also need something solid to crash into.

The terrain in Supersonic Fight is generated procedurally, which means I cannot simply model collision meshes by hand. Instead, they have to be created using the same process that builds the visible terrain.

The process starts on the GPU. The terrain is rendered exactly as normal, allowing all of the procedural height modifications and terrain layering to happen, but rather than drawing the result to the screen, the data is written into a texture. That texture is then sent back to the CPU, where a mesh can be reconstructed and simplified before being handed over to the physics system.

It's not the most glamorous system in the game, but it's absolutely essential.

The images below show the process:

1. Raw height data combined with satellite imagery

The starting point is relatively low-resolution terrain data overlaid with satellite imagery. At this stage, the landscape still lacks much of the detail seen in-game.

2. Procedural height modifications applied to the vertices

Additional detail is added on the GPU, sculpting the terrain and dramatically increasing the apparent resolution.

3. Procedural terrain layers applied in the pixel shader

Different terrain materials are blended together based on height, slope and a range of other parameters, producing the final appearance.

4. Generation of a regular collision mesh

Once the final terrain shape has been captured from the GPU, a collision mesh can be reconstructed on the CPU.

5. Simplification of the collision mesh

Finally, the mesh is aggressively simplified to keep the triangle count as low as possible while still accurately representing the landscape.

Tackling collision at this stage is not just so that players have something to crash into - it also gives me a way to determine the terrain height at any point on the map. This is especially important for the next step: planting forests across the landscape!

Want to see more behind-the-scenes development and chat with other pilots? Join the Discord community: Discord Link

-Rich