src/projects/voxel-gen/page.tsx
workspace/projects/voxel-gen

80k x 80k Procedural Voxel Generation

Procedural Generation
Role

Lead Performance & Systems Developer

Timeline

Apr 2024 - Jun 2024

-- Source Code

heropeak_generator_script.lua
luau
1local isWorker = script.Parent and script.Parent:IsA("Actor")
2
3if isWorker then
4 -- BACKGROUND WORKER LOGIC
5 local actor = script.Parent :: Actor
6 local ProgressEvent = actor:WaitForChild("ProgressEvent") :: BindableEvent
7
8 local EROSION_ITERATIONS = 3
9 local MARGIN = 4
10 local GRID_DIM = Config.CHUNK_SIZE + 2 * MARGIN
11
12 local poolHeightMap = table.create(GRID_DIM)
13 local poolNextMap = table.create(GRID_DIM)
14 for i = 1, GRID_DIM do
15 poolHeightMap[i] = table.create(GRID_DIM, 0)
16 poolNextMap[i] = table.create(GRID_DIM, 0)
17 end
18
19 local Config_CHUNK_HEIGHT = 256
20 local rowPoolMat = table.create(Config.CHUNK_SIZE)

-- Description

Designed and implemented a highly optimized, multi-threaded procedural generation system capable of deterministically synthesizing giant voxel landscapes spanning 80,000 by 80,000 spatial units. The architecture utilizes a distributed, asynchronous Actor-Pull model in the Parallel Luau ecosystem, where a central dispatcher coordinates task prioritization using a spiral index mapping algorithm. SharedTable structures are utilized to pass data between threads with zero memory-copying overhead. Terrain topology is evaluated using multi-octave Perlin noise integrated with multi-dimensional domain warping, applying non-linear mathematical filters to eliminate vector singularities and grid artifacts at coordinate extremes. To circumvent the platform's strict memory allocation constraints (which would otherwise result in a 26GB memory footprint), I designed a dynamic shell thickness estimator to prune the internal octree. By analyzing local topological gradients, the system dynamically adjusts octree depths, forcing Empty Mips compression in deep subterranean structures while preserving fine details on high-contrast vertical cliffs. Additional features include custom I/O pathways that bypass standard diagnostic memory dump cycles, a failsafe deadlock detection subsystem, and a hybrid plugin context that allows direct serialization of billions of voxels to static persistent memory.

-- Technologies

Parallel LuauSharedTablesOctreesPerlin NoiseDomain Warping

Challenges

Mitigating 26GB alocation-induced memory limits in closed runtime environments, preventing data-race hazards during high-frequency parallel terrain calculations, and avoiding mesh artifacts at coordinate extremes.

Solutions

Designed an Actor-Pull parallelization pipeline with read-only SharedTable buffers, developed a gradient-based octree shell compression technique, and implemented direct binary serialization bypassing standard buffer translation.

-- Snippet

voxel-gen.luau
local p = workspace:FindFirstChild("ProceduralVoxelGen")

// EOF - Built with Next.js, Tailwind CSS & Framer Motion