Cubed

January 2024 — Present Personal project
  • C
  • Vulkan
  • GLSL
  • Hardware raytracing
  • Global illumination

Cubed is a real-time voxel rendering engine written from scratch in C and Vulkan. It uses hardware raytracing to render each scene, with a compute-shader backed fallback when it is not supported. It supports real-time dynamic illumination via a novel algorithm I dubbed Hierarchical Voxel Irradiance Caching. I write it up as I go in a series of video devlogs.

Highlights

  • Raytracing pipeline on Vulkan hardware RT, with a compute-shader software fallback and a wide BVH accelerator.
  • Several voxel data structures: 64-trees, brickmaps, and flat volumes, each with a custom intersection shader. Profiling in Nsight surfaced cache misses; reworking the memory layout cut frame times ~20%.
  • Indirect dispatch builds a world-space octree forest under a fixed memory budget, backed by a custom Vulkan allocator. It drives infinite-bounce GI with screen-space-constant probe sizing.
  • A cascaded shadow map with PCF drives both primary shadows as well as direct light queries for GI rays.

Media

A large forest scene (~2B voxels) rendered in real-time.
A large forest scene (~2B voxels) rendered in real-time.
Dynamic hierarchical global illumination.
A screenshot showing correct multi-bounce lighting in the engine.
Correct multi-bounce lighting.