r/VoxelGameDev • u/paulpach • 1h ago
Discussion No floats in worldgen: how I keep every client's terrain identical, except the ores only the server knows about
I'm making Cubica, a multiplayer voxel survival game in Unity (DOTS). Two decisions shaped the whole terrain pipeline, and I'm curious how others here handle them.
1. Not a single float in the generation path. The server and every client generate chunks from the seed instead of streaming them, so they must agree bit for bit. x86 and ARM phones don't always round the same float expression the same way, so the generator is integer-only: noise is quantized to a fixed range right away, thresholds are integer compares, and structure placement uses an integer hash (hash % 1000 < 300, never Random.value < 0.3f). Villages, rivers, caves and mine shafts all come out of the same pure function of seed + chunk coordinate. Only player edits travel over the network, as a patch layer on top of the generated chunk.
2. Ores are not part of that function. If clients could generate ores, a modified client could x-ray the whole world. So ore placement is keyed by a 128-bit per-world secret that only the server has. Clients generate plain stone where the server has ore (same collision, so movement still predicts correctly). An ore only reaches a client when one of its faces gets exposed, or when a patch changes it.
Storage: 16x256x16 chunks, base blocks as an immutable 128 KB blob (2 bytes per block, Burst-readable), edits as a small patch buffer on top. Structures are baked to RLE blobs with a per-column index, so stamping them in the generation job needs no decompression.
The tradeoff I'm still weighing: every worldgen change bumps a generation version, because old saved patches only make sense on top of the terrain they were made on.
Anyone else running integer-only noise? I'd love to compare notes on how you handle smooth-looking terrain with 8-bit quantized noise.
(Open alpha if you want to walk around in it: https://cubica.net/download/ , Discord: https://discord.gg/fWE2YWChc)