Procedural World

Procedural World

I’ve been working on some prototypes with regards to generating procedural worlds recently, having been inspired quite a bit by this excellent series on polygonal map generation, and this great blog. I’m trying to go for something a bit different than what I think they’re after, but there are a lot of great ideas there.

(For those that don’t know, “procedural world” just means “giving a program a set of rules so it can build a world from scratch without any human intervention”)

One of my goals with this project is to try to generate a procedural world where there are still “dramatic points of interest”, if you will. When I say dramatic, what I mean is that some areas should feel differentiated and special, it shouldn’t feel too uniform. One of the problems with generating a world is that there’s sort of a sameness to everywhere, which I’m trying to avoid.

This is what my most recent attempt looks like, a quick hack-up C# app that I can also hook into Unity:

 

The idea is to generate a “feature map” describing what the dominant features of each area is, and then generate the terrain based on that. Why not generate the heightmap first and then the features? Mostly because the feature map is relatively clean in terms of being simple convex polygons which are easy to reason about programatically and mathematically. I have a lot of code that tends to be of the variety of “if this area is surrounded by these certain features, do this certain thing”. Height maps are pretty messy, so while you could go the perlin noise route and generate the terrain first, and then try to classify each area later, I thought it would be somewhat easier just to  throw down the polygons first, and then figure out a heightmap that works for it. I think that approach creates something that’s a bit less realistic, but I’m mostly happy with the results so far, although I feel like it could use quite a bit of post processing to look a bit more natural (hard to see from the screenshot, but the transitions are very rigid at the moment).

The goal with the feature maps is mostly to ensure that I end up with something playable in a deterministic way (ie, you can run checks against it and so on), which I think is a bit hard when you’re just working off pure noise.

In this screenshot, the different feature areas are color coded. In this case, the green areas are “highlands”, and the teal areas are canyons, and the dark green areas are bits of forest or foothills.  (You can guess what the blue and grey ones are). The hard to see orange squiggly areas are a (very rough) stab at defining road layouts for towns, although the towns are unconnected at the moment.

You can get a clearer idea of that from the base feature map below, which the above was generated from:

 

Basically this is just voronoi noise polygons + lloyd relaxation + sampling from a noise source w/ some rules, a lot like the link to Amit’s series above. I still feel like this is all a bit too random at this point though. It lacks points of interests. The next step is going to be to run some simulations across the generated landscapes to come up with more of a world with something of a story to tell.