Voxels


Voxel generation and customization abilities - using Dagmar, massive voxel worlds can be created, dynamically loaded and explored.

Generation
The world is generated using a combination of 2D simplex noise, used for creating the terrain, and 3D simplex noise to carve into the 2D generated surface in order to create complex landscapes. The terrain generation can be changed to only 2D noise, for a smooth terrain, or only 3D noise for a complex alien-like landscape. The noise sampling can be customized from the engine, as well as the size of the voxel world. The water level and foliage can also be modified - the tree and flower density functions can be changed, as well as the minimum and maximum height and width of trees.

Optimizations
Each voxel contains information about its contents: if it is empty or not, and if so, what type of cell it is. The voxels are stored in a voxel chunk, which represents a three dimensional space. Each voxel's position is implicit, based on the order in which they are saved in the voxel chunk. This helps to decrease memory usage. The world consists of multiple voxel chunks and they can independently be loaded, rendered and unloaded. The voxel chunks' positions are also implicit and are computed based on their relative offsets in the voxel manager's storage.

The voxel entity can focus another entity and load chunks only around it for better performance. The total size of the world can be modified from the editor, as well as the load size around the focused entity.

Destruction
The voxel world is fully destructible in play mode, from a camera or player entity. The forward vector of the player is used as a ray which is divided into fixed intervals. If a point on the border of two intervals is found to be inside an active voxel, the voxel is set as inactive, physics-based particles are spawned randomly around the voxel's centre with the voxel's colors, and the mesh is regenerated to account for the destroyed voxel.

Rendering
The entire voxel entity is rendered as two meshes: the terrain with foliage and the water surface, both created at run-time. If two voxels are active and they are both water or both non-water, the face between them will not be added to the mesh because it is not visible - only the surface encompassing the active voxels is created and rendered. The separation between water and non-water meshes has been done such that ordered rendering of opaque and then sorted transparent objects can be done.