Devlog Devlog #4: Procedural Asteroid Fields

An important part of the experience of drift will be traversing the asteroid field you find yourself in. Today I'll talk about moving beyond random placement and into intentional generation.

Procedural placement of uncolored asteroids
Procedural placement of uncolored asteroids

Creating an "interesting" asteroid field is a challenge because there is no clear answer to what that requires. But the first piece that I'm tackling this week is asteroid placement. The first versions of the game had no asteroids outside of the small debris. Later version had a large, dense field but that was created with random noise and often felt boring past the first group.

First off - let's address the elephant in the room. Procedural generation is a mixed bag when creating content. When over-relied on it creates games thare a infinitely wide and infantessimally deep. I know this, and I've felt it in many games. But I also have seen it done well - and my aim is to follow in their footsteps. And if I miss the mark, I'll go back to the drawing board.

Showing the spacing spheres of the Poisson-disc inspired distribution
Showing the spacing spheres of the Poisson-disc inspired distribution

The first step of generation was all about placement. How can we efficiently place thousands of asteroids, with varying sizes, without overlapping each other in 3D space? In the 2D world, there is a algorithm called Poisson-disc sampling. In this, we have a function that creates a tightly packed natural pattern of points to fill in a space. Expanding that to 3D was simple enough using spheres. But in this case, I didn't want evenly spaced points (even if they were more natural) - as many of the asteroids in the field will have significant size to them.

With further adapation, the algorithm now takes in variable radii to space each asteroid differently depending on its size. We then generate placement points for each section of the field and take a sample of those points to actually place asteroids there.

While I'm happy with the current output, I'm looking to make the following improvments as I continue:

  • Reduce the spacing radius near a large asteroid to simulate it's gravity draw
  • Potentially influence our points we sample to follow a pattern (e.g. milky way arms)

There will be much more to share about the asteroid field (biomes, colors, skybox) and what to find inside as we get closer to Early Access!