Maybe Tomorrow… A Perfect Voxel Engine

There’s a world that’s waiting for me, A voxel dream, so wild and free, With LOD and streaming from the disk, I know it’s a challenge, but it’s worth the risk.

Maybe tomorrow, I’ll find the path I seek, With optimized chunks and smooth updates, My engine’s future’s looking sleek.

Maybe tomorrow, I’ll conquer every code, With LOD and disk streaming, A voxel world, my ultimate abode

ChatGPT-4o prompted “write me a few line of a song based on the Littlest Hobo Theme song, Maybe Tomorrow about rewriting my voxel engine to include LOD and streaming from disk”

There were a number of short comings with the old voxel engine.

  1. The chunks (groups of voxels) that made up the world were fixed 3D array
  2. The voxel meshes were not designed with LOD (level of detail) in mind

These two flaws would prevent:

  1. Streaming the world from disk so parts of the world could be dynamically loaded/unloaded from memory allowing for much bigger worlds
  2. Reducing the complexity of the voxel meshes so the number of polys could be decreased based on the distance from the player putting less load on the GPU

In a few hours taking the learning from the first engine I started from scratch on a new project that resolves these issues and also is going to world abstraction and pathfinding to be considered from the very start.

In the video below the red dot representing the player is a 1 unit sphere. The world is made up of chunks that consist of 16×16 single unit square voxels. As the player moves right through the scene chunks are added/destroyed based on the distance from the player. The logic to add/remove the chunks and build the mesh data are being done on a background thread. The mesh itself has to be created/modified on the main unity thread.

Couple more learning have been implemented as well, like using object pooling for the voxels and the meshes so those objects do not need to get released and recreated. As the new chunks get loaded/destroy only get a small single frame slow down Unity main thread work is done.