Back to projects
Procedural Generation

80k x 80k Procedural Voxel World

Role: Systems Programmer
Timeline: Apr 2024 - Jun 2024

Code Preview

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)

Overview

A multi-threaded procedural terrain generator designed to stream an 80,000 x 80,000 voxel map on Roblox at 60 FPS. Calculations are distributed across worker threads using Parallel Luau, and memory usage is kept under ~300 MB through hierarchical octrees and dynamic surface-only shell pruning.

Stack

Parallel LuauSharedTablesOctreesPerlin NoiseDomain Warping

The Hard Part

Generating large terrain without running into Roblox memory limits or freezing the main thread during batch generation.

How It Was Handled

Dispatched chunk math across an Actor worker pool, stored only visible surface voxels in memory, and generated chunks outward in a spiral around the player.