Vulkan Voxel Engine

A Real-Time Raytraced Voxel World Engine
by Hendrik Sorensen

Project Overview

Vulkan Voxel Engine is a next-generation, real-time voxel world renderer and simulator, built from scratch in C++ and GLSL. Leveraging Vulkan's hardware-accelerated raytracing, it delivers stunning visuals and high performance, featuring a fully procedural, multi-threaded terrain system. This project demonstrates advanced graphics programming, GPU compute, and modern game engine architecture.

Built for performance: Real-time raytracing, multi-threaded chunk generation, and efficient GPU memory management.
Procedural worlds: Every landscape is unique, generated on the fly with FastNoiseLite.

Key Features

Chunked Voxel World

8x8x8 grid of 128³ voxel chunks (512 total), dynamically loaded and managed for seamless exploration.

Real-Time Vulkan Raytracing

Hardware-accelerated raytracing pipeline for primary and secondary rays, delivering cinematic visuals.

Procedural Terrain

FastNoiseLite-based, multi-threaded terrain generation with rich material assignment (stone, grass, flowers, etc.).

Efficient Voxel Storage

Bit-packed, chunked, and stored as GPU 3D textures for fast access and minimal memory usage.

Raymarching in Shaders

Custom GLSL march function for LOD-aware, efficient intersection and traversal.

Dynamic Chunk Loading

Multi-threaded chunk generation and prioritization based on camera position for smooth streaming.

Optimized Memory Usage

Chunk recycling, minimal GPU transfers, and LOD-based skipping for high efficiency.

Technical Deep Dive

Chunk System

  • World divided into 8x8x8 chunks, each 128³ voxels (512 total).
  • Chunks stored as 3D textures on the GPU (VK_FORMAT_R8_UINT), with a chunk map (VK_FORMAT_R16_UINT).
  • Chunk queue and worker threads for background generation and updates.
  • Chunks repositioned and recycled as the player moves, minimizing memory usage.

Generation System

  • Procedural terrain using FastNoiseLite for natural landscapes.
  • Multi-threaded generation: each chunk is generated in parallel for fast world creation.
  • Material assignment (stone, grass, flowers, etc.) based on noise and position.

Voxel Storage

  • Each chunk: 128x128x128 array, stored as uint8_t (5 bits material, 3 bits LOD/layer).
  • Chunks uploaded to GPU as VK_FORMAT_R8_UINT 3D textures.
  • Chunk map (8x8x8, VK_FORMAT_R16_UINT) maps world positions to chunk IDs.

Raytracing

  • Vulkan raytracing pipeline (VK_KHR_ray_tracing).
  • Ray generation and miss shaders (rgen.glsl, rmiss.glsl).
  • Raytracing command buffers run in parallel with rasterization.
  • Shaders sample voxel textures and perform LOD-aware intersection.

Raymarching

  • Custom march function in GLSL: steps through the world, using LOD/layer info to skip empty space efficiently.
  • Combines ray-box intersection and LOD-aware stepping for fast traversal.
  • Returns hit info, color, and material for shading.
  • Used for both primary rays and secondary bounces (reflections, GI).

Example: Voxel Bit Packing (C++)

// 5 bits material, 3 bits LOD/layer
#define voxel_mat(voxel) ((voxel) & 0b11111)
#define voxel_base(voxel) (((voxel) & 0b11100000) >> 5)

// Efficiently store and retrieve voxel data
uint8_t voxel = ...;
uint8_t material = voxel_mat(voxel);
uint8_t lod = voxel_base(voxel);

Optimization

These optimizations allow the engine to render large, detailed voxel worlds in real time, even on consumer hardware.

Demo & Showcase

0
Lines of C++ Code
0
Voxel Chunks
0
Voxels per Chunk (per axis)
0
FPS (Real-Time Raytracing)

How to Build & Run

  1. Ensure you have a Vulkan-capable GPU and recent drivers.
  2. Clone the repository from GitHub.
  3. Open a terminal in the VoxelEngine directory.
  4. Run the following commands:
sudo make run

Rendering Pipeline & Visuals

The Vulkan Voxel Engine uses a unique multi-pass raytracing approach for real-time rendering and lighting. The process is visualized below, with each step illustrated and explained.

Step 1: Raytracing Passes & Lighting Accumulation

Lighting Dots Visualization

Lighting contributions (dots) being accumulated per voxel

Step 2: Color Rendering Pass

No Fog Visualization

Voxel colors rendered without fog

Full Color Visualization

Final color output with all lighting applied