We use procedural generation to create a 3D environment for the prototype of our game, Avoyd. Our main reason for employing the technique is to keep the download size small. Avoyd's a voxel game in zero gravity. This means that all surfaces can be traversed in any direction: players can fly but also attach themselves to any surface and hover. In addition volumes can be edited in-game. The game prototype features a fair amount of destruction, so we mix materials of varying hardnesses to show off these properties.
Inspired by concept art by Rebecca Michalak, we went through many iterations and by trial and error ended up with a structure made of clusters of boxes linked by bridges. Using voxels simplifies much of the procedural generation since operations such as adding and removing volumes are fairly trivial to implement. Most of the variables such as box dimensions and group sizes are randomly chosen within boundaries. Here's how we progressed from a simple voxel cube to clusters of greebled boxes made of a selection of materials:
To get these towers, draw a white cube, add greeble to the whole surface by adding a random number of flat metal rectangles smaller than the side they’re added to, and hollowing them out by removing a box 2 voxels smaller offset by 1 voxel to the center of the metal rectangle.
Move one cube length along an axis, add a new cube and greeble it, repeat.
To hollow out a cube, delete random smaller boxes inside.
Cubes become boxes (random dimensions along each axis). Some of the surface greeble is not hollowed out: they look like metal plates. Instead of stacking the boxes along an axis, they are placed randomly side by side and linked by planks/bridges. From one side of each bridge we create a navigable path by removing a box shape the width and length of the plank bridge but taller. Some of the metal planks are dead ends that lead to a metal "safe room" (metal is a harder material to destroy) built using the same rules as the white boxes.
Randomly colour the boxes using neighbouring materials (materials are identified by incremental numbers and colours). Each box is first created full, then we overwrite the inside with smaller boxes made of different materials/colours. Following that, each box is greebled and hollowed.
Here we're only using one materials family (colours white and grey) to take a closer look at grouping the boxes in clusters.
Grouping in clusters and multiple material families (colours) combined
As before, but in a very large world. It looks a bit messy.
Trying to add structure and landmarks by lengthening some of the boxes a lot.
Grouping into clusters again: each cluster has a dominant axis the boxes are lengthened along, and a single material family. Each material family has a dominant colour: white, ochre, red, green, blue, and various strengths. The white family is used about twice as often as the others, though this is only detectable in large worlds made of many clusters.
During gameplay, players and drones firing damages the generated world. This is damage caused by a drone battle in a red cluster. Strong materials take less damage than weak ones. In the current build, Avoyd 0.3, materials do not shield each other.
To get an idea of the result, you can download Avoyd from our website.
When playing the game, the procedurally generated boxes described above are the default environment. The game also features a Voxel Editor which can be used for generating the procedural boxes. A small number of parameters can be tweaked. To familiarise yourself with the editor, follow the tutorial in Avoyd's Voxel Editor's "Help > Tutorial" to "Create a simple shape with 'Set'". To try out the procedural generation, 'Set' the shape called "Procgen: Linked Boxes". Use a large box size for better results although the scene will take longer to generate.