Mosaic

A voxel engine built from scratch. Real-time global illumination, ray-traced shadows, procedural worlds.

Rust + wgpu — ~32k lines of code

~32k
Lines of Rust
2,200
Chunks per draw call
256³
GI voxel volume
<1ms
Chunk load (zstd)
8
Biomes

Engine Features

Everything built from the ground up — no game engine, no shortcuts.

Voxel Global Illumination

Real-time GI in a 256³ voxel volume using DDA ray marching. Hard and soft shadows via voxel tracing — no shadow maps. Per-vertex AO baked with DDA hemisphere tracing using Amanatides & Woo traversal.

Binary Greedy Meshing

Reduces triangle count 10-20x versus naive cubes. Multi-draw indirect rendering batches ~2,200 chunks into a single draw call. 4 LOD levels by distance with compute shader frustum culling on GPU.

Volumetric Lighting

God rays via a 3-pass pipeline: half-res DDA ray march, bilateral blur, and composite. Temporal dithering with Henyey-Greenstein phase function, adjustable 24-72 sample steps.

Water System

Heightfield rendering with pipe-model flow simulation. Ray-marched fullscreen water pass with wave animation, Fresnel reflections, refraction, and underwater fog.

Procedural Worlds

8 biomes (grasslands, desert, jungle, tundra, mountains, ocean, swamp, cavernous highlands) with 3D Perlin caves, ore veins, procedural trees, vegetation, and ruins. Region file persistence with zstd compression at 3:1 ratio.

Spatial Audio

3D positional audio with material-based sound categories. DDA raycast occlusion crossfades ambience between environments. Convolution reverb in caves, footstep material detection, and music system with crossfade transitions.

Character System

3rd-person camera with skeletal animation and FBX model loading via ufbx. Character customization for outfits, hair, and heads. Body part editor with bone-driven skinned meshes lit by the voxel GI system.

Post-Processing

Hybrid morphological-temporal AA with depth edge detection, pattern matching, temporal accumulation, and sharpening. Depth of field with near/far blur layers. Bloom, SSAO, and greedy-meshed voxel clouds with terrain shadows.

Under the Hood

Some of the implementation details.

Rendering Pipeline

  • Sky pass — procedural atmosphere
  • Opaque geometry — MDI mega-buffer batching
  • Characters — skinned meshes + voxel GI shadows
  • Water pass — ray-marched heightfield
  • SSAO — screen-space ambient occlusion
  • Volumetrics — DDA ray march + blur + composite
  • Post-process — DoF, AA, bloom
  • UI — hotbar, debug overlay, menus

Architecture

  • wgpu — Vulkan/DX12/Metal abstraction
  • 19 WGSL shaders — compute + graphics
  • 8 worker threads — generation, meshing, lighting
  • Lock-free channels — crossbeam MPSC queues
  • Region files — 32x32 chunk sectors, zstd compressed
  • SlotMap ECS — generational arena, O(1) lookup
  • Priority task system — player actions bypass gen queue
  • Criterion benchmarks — meshing, shadows, generation