Voxel Game Engine

An engine that manages rendering and game logic for a voxel based 3D world.

Introduction

This is a voxel game engine which allows for the creation of procedurally generated infinite worlds. Variations in rock types, soil types and biomes create an immersive experience in which exploration is endorsed. The world loads and unloads automatically as players move and allows them to remove or add blocks as desired.

The source of this project can be found on GitHub.

Planet Matter

Architecture

This application follows a monolithic architecture. Using CMake, multiple targets are declared which handle separate concerns. By passing flags to the build command, developers can compile for different architectures and graphics drivers. Constants are declared automatically which tell the compiler which back ends to use.

Windowing and Graphics

Portability is always an issue in game engines, which is why this application defines an abstract interface for both windowing and graphics. This allows for multiple back ends to be defined for different targets without changing the implementation of unrelated parts. To ensure that the least amount of overhead is introduced, virtual methods are avoided. Therefore, static polymorphism is used, where implementations differ by build target but header files are the same.

Shaders

Given that the system provides multiple graphics back ends with the same interface, shaders must also be adapted. Although OpenGL and Vulkan both utilize GLSL, specific alterations must be done for each driver. For this purpose, and considering future considerations regarding custom scripting languages, a common shading language was declared. This is analyzed using a lexer, parser and semantic analyzer. Afterwards, the result is compiled to the correct target during build time.

Terrain

In a voxel engine, terrain is defined by a 3D grid of voxels, which are 1x1x1 blocks in space. Each block has an associated type. Terrain generation occurs by the creation of Perlin noise maps for altitude, temperature, humidity and other factors. Based on the noise provided, a block type is selected for the location. This allows for rock variation in the lower layers of terrain, specific soil types depending on humidity and sediment, and biome selection that conforms to the temperature, humidity and underlying soil.

Players can interact with terrain by pressing right click to place a block, or left click to remove blocks. The system automatically processes this action by updating neighboring blocks and updating the final mesh the user receives. The user will see the updates to the world afterwards.

Entities

To avoid the common pitfalls of traditional entity hierarchies, this system utilizes the ECS (Entity Component System) pattern. This way, components are declared which define behavior. An entity can be created by assigning various behaviors to it. Various systems, like physics, input and others, will reference entities by their associated components, acting only on entities whose behavior is understood by the system.

Planet Matter
Planet Matter
Planet Matter