[World Machina] Dev log 0

[World Machina] Dev log 0

May 02, 2025

Hey 👋, this is the first time I've done something like this. This project started a couple weeks ago and since then I've made quite a lot of progress.

This started when I was writing a campaign for pathfinder. I wanted to have a planetary map so the players could visualize where they were and make notes as to where they had been and found different things. There are very few resources that matched my use case, I wanted a physically accurate map for my world but most tools for large scale maps just used fractal generation and noise. Or were very low resolution, or were very high resolution and accurate for a small non-tiling chunks.

This was quite annoying as I couldn't find my Goldilocks tool so I figured hey I'll just try to make one, how hard could it be?

As it turns out I was very very naive.

It is possible... but at what cost?

So I started outlining everything I needed to do to make a physically accurate planet. To start, tectonic simulation for accurate land masses, this was my first hurdle and something that still needs to be tackled with a more versatile implementation as the current implementation is a little restrictive but for now it will do, it produces good results just quite slowly.

image

The above is the kind of heightmap it generates, this is really nice.

Ok tectonics. Good enough for now.

Now what next, it would have to be erosion, but what kind? I actually didn't realize how in-depth this question would be. For now I've settled on the main one hydraulic erosion, this works by simulating how water shapes landscapes through a cycle of rainfall, flow, and sediment transport. As water moves across terrain, it picks up soil particles from higher elevations and deposits them in lower areas, gradually carving channels and valleys while building up floodplains and deltas.

The beauty of hydraulic erosion lies in its emergent complexity from simple rules. Each water particle follows the path of least resistance downhill, carrying sediment proportional to its velocity. When water slows down, it deposits sediment; when it speeds up, it erodes more material. Over many iterations, these basic interactions create remarkably realistic terrain features all without explicitly programming these structures.

The implementation I'm working from has some quirks that limit its usefulness for my goal. So a large part of time was figuring out how to mutlithread this problem and in tern figuring out how to create a wrapping tileable solution, which I did, thank goodness.

image

Working with planetary-scale erosion means dealing with absolutely massive heightmaps. The original algorithm would simply choke on these sizes. My solution? Break the problem into tiles. Rather than processing one enormous heightmap, I split it into manageable chunks that each fit comfortably in memory. But this isn't as simple as just cutting up the image - I needed to ensure water could flow naturally across tile boundaries. Each tile gets generous overlap regions with its neighbors, so water particles near the edge have a natural continuation path. I also implemented proper wrapping for the planet - water flowing off the eastern edge correctly appears on the west, and similarly for north/south poles.

To speed things up, I went in on multithreading. Each tile gets processed independently on a separate CPU core - this turned what would have been days of processing into hours. But memory became the my main next bottleneck - with scaled-up tiles, my under powered laptop was struggling. So I implemented a disk-based swap system where completed tiles get saved to temporary files and only loaded back into memory during the final stitching phase. This lets the code handle absolutely enormous output resolutions.

The stitching phase is where the magic happens - tiles get carefully blended together using a weight mask that gradually transitions between overlapping regions. This prevents any visible seams while ensuring water erosion patterns flow naturally across boundaries. The weight mask gives more influence to the center of each tile and less to the edges, creating a smooth gradient between tiles. I added progress tracking and automatic cleanup of temporary files so your drive doesn't fill up with swap files. The final system can handle planetary maps at resolutions that would make traditional erosion algorithms collapse. Is it overkill for a Pathfinder campaign? Absolutely. Was it worth it? Also absolutely.

From a low resolution tectonic simulated heightmap like the one below, we can now make some really high resolution images.

image

image

These results are really really nice.

As of right now that's the extent of what I've gotten working. I'll continue with my todo: https://github.com/SAED2906/WorldMachina/blob/main/todo.md in between my uni courses.

Подобається цей допис?

Купити для William Marais каву

КонфіденційністьУмовиПоскаржитись