What is procedural generation?

How does it work?

Procedural generation sounds really complicated but it is a very simple concept at its core.

It just means a computer created parts of it by following a recipe.

Which part was created by the computer is the interesing part.

Imagine someone tells you to draw a tree with a lot of leaves. They dont tell you precisely how each leaf of the tree should look, rather they give you a general idea. You can then draw the tree with your own knowledge of how that works. And given different instructions you can draw the tree differently. For example with a different coloured trunk. Or taller? Or more branches?

You get the idea.

That is basically procedural generation but you drew the tree and not the computer.

In computers this process is similar. Somebody has to teach the computer how to draw a tree. You build an algorithm for that first. Just like you can train drawing trees on paper. And that algorithm can have certain inputs like the color of the leaves or the shape. Like you can get instructions on how somebody would like their tree to be drawn.

Using its algorithm the computer can then draw a tree with the leaves you want. And with much more complicated inputs we can specify the shape and size of the tree.

But the magic of procedural generation is that its not limited to drawings of trees. Anything that can be turned into an algorithm can be used by our computer.

This is where the term "procedural" comes from. Procedural just means procedure. So if you can find a procedure to create something that's procedural generation right there.

How does it help me?

Procedural generation is used in all kinds of applications today. Most visibly in modern computer games.

Have you ever played a game where levels or missions are different each time you play them? But it still looks similar, almost a pattern in the design?

Thats a procedural algorithm that creates your level differently each time you play.

Notable examples of large scale procedural generation include minecraft and no-mans sky.

They have created basically infinite gameworlds by using algorithms to their advantage. Minecraft can generate millions of different worlds and no-mans sky gives you a universe to explore so big you would die of old age before you visited every system.

But, and here comes the danger of using procedural generation too much:

The levels are similar so you feel like they are the same game. Use too much computer generation and whatever you create becomes boring. Some players of these games complain that despite infinite gameworlds, at some point you have seen it all and the structure of the algorithm becomes apparent and the game is boring. Sounds can be turned into music but a metronome is not a very interesting song isn't it?

This means, developers and artists have to be careful where and to which extent to use the aid of computers. People will notice the patterns that are in your works. So you need to find a way to make it interesting and not repetitive.

Depending on your individual use-case, you can use algorithms like perlin noise or L-Systems to create everything you imagine.

If you want to use these algorithms yourself, you can absolutely do so, but be warned, this can involve a lot of mathematics the deeper you dig. This is another downside of procedural generation algorithms. The complexity however is largely dependent on the particular use-case.

So, procedural generation can help you create way more stuff like game levels, textures (yes even textures can be created using algorithms) or missions (even storyline is procedurally generated in some games).

If you are just experimenting with procedural tools, start small to keep complexity at a manageable level.

Is it AI?

No, it is not.

Although AI seems to be everywhere now, procedural generation is a little more specific than that. Procedural generation is a handcrafted algorithm most of the time. It involves careful tuning and testing to produce the results a designer wants. AI are large systems that are trained on data and not built by hand. The use of generative ai is a different way artists can increase and diversify their output. But that is not todays topic.

Where to get started

A very nice way to experience procedural generation first hand is to experiment with heightmaps and perlin noise.

If you are working with a tool that can use textures to define the shape of the terrain, you can use perlin noise to generate lots of different heightmaps for you.

Perlin Noise black and white image.

You can experiment with perlin noise on this generator tool by Mark McKay. You dont have to know code, just try a few values and see what you get. The images can be downloaded and used as heightmaps in the software of your choice. Most game engines for example support images as heightmaps. Some even have noise-tools built into them.

Minecrafts world generation also depends on noise. Tools for the game such as Worldpainter or worldsdesigner do the same.