This Minecraft-inspired project showcases the creation of an infinite 3D world using procedural generation in Westlake Engine. The procedurally generated landscape features diverse biomes and natural formations including caves and trees, enhanced by a dynamic lighting system. The world continuously generates as players explore, offering an endless, immersive environment similar to Minecraft's signature gameplay experience.Â
This project features:
Perlin Noise.
The world's features are created using Perlin noise, which generates natural-looking random patterns. This mathematical technique is applied to various aspects of the world:
Ground elevation (how high or low the terrain is)
Hill patterns (how rough or smooth the landscape appears)
Ocean distribution (where water bodies form)
Climate zones (how temperature varies across regions)
Moisture levels (how wet or dry areas are)
Forest coverage (where trees grow)
Volcanic activity (where lava appears)
The following code demonstrates how we construct a single chunk's complete dataset using Perlin Noise algorithms:Â
The cave generation system utilizes a "Cave Digger Machine" algorithm. The process begins by selecting a potential starting point within a chunk. This point's viability is evaluated using Perlin Noise calculations to determine if it's suitable for cave formation. Once a valid starting point is established, the machine begins digging. It operates by simultaneously extending in two directions - forward and backward - with randomized directional paths and distances. As it progresses, it hollows out the chunk in a three-dimensional capsule pattern, effectively creating natural-looking cave tunnels. Here is the main logic of the algorithm:
The world system leverages the asynchronous job system to handle several concurrent operations:
As players explore, it dynamically constructs new terrain chunks or retrieves previously saved ones from the saved data folder
When chunks fall outside the player's view distance, it cleans them up by removing them from active memory
For any chunks where the terrain or objects have been modified, it persists those changes by writing them to save files
During each frame of the Update cycle, the main thread focuses on two exclusive tasks:
Deactivating chunks that are too far from the player, or
Using the asynchronous job system to queue activation requests for chunks within the player's range
Meanwhile, other threads handle the work by responding to these job system requests. These worker threads are responsible for generating or loading new chunk data, depending on what's needed for their assigned chunks.
This system allows the main thread to stay responsive while the resource-intensive work of chunk generation and loading happens concurrently on other threads.
The light spreads by checking neighboring blocks - each new block's brightness is set one level dimmer than its brightest neighbor. This creates natural light falloff as it spreads outward.Â
The chunk-saving system works by:
Creating a binary file for the modified chunk that is being deactivated
Writing the values of every block in that chunk to the file in binary format
This makes the loading process straightforward - the game simply needs to read through the binary file byte by byte, using each value to reconstruct the chunk's block data. This binary approach is more efficient than using text-based formats for saving and loading chunk data.
Load Data and Save Data functions