Procedural generation is when you create something by using an algorithm, rather than hand-making it.
Peddle your definitions elsewhere, you say. What does it actually mean?
I think this can be best illustrated with examples. Consider standard Mario platformers – you know, the 2D ones where you go from left to right jumping on turtles and stuff.
Those levels are hand-made – designers created them.
Now consider a game like Minecraft. Minecraft worlds are not hand-made. Instead, they are generated by an algorithm.
An algorithm is a set of instructions that detail how to do something. For example, consider adding the numbers 1076 and 542 by writing out the addition. You go from right to left adding the columns, and carry if necessary. You followed an algorithm when you did this.
Procedural generation is quite useful. You write an algorithm once, and can generate many things (levels, for example) from it. This is in contrast to hand-made content, which is the same for everybody (e.g. the first level of Mario).
Procedural generation is used in a number of places. It can be found most commonly in games, but also in other places like special effects (e.g. floating islands in Avatar).
Blah blah blah, you say. Show me the dancing unicorn!
Unfortunately, the dancing unicorn was injured during its last performance, so I can’t do that. I do have a pretty picture, though:
This is the ocean, complete with seaweed and fish. Notice that it is made out of little blocks.
The picture was made with procedural generation. Each of the elements in this picture are generated separately, one after the other.
We start with the water:
Now, let’s add some sand:
This is a bit more complex. How was the sand made? Remember, everything in the picture was created by an algorithm.
The sand algorithm works column-by-column, starting on the left. We start with a random height. Each column, we fill sand up to that height. Then, we either move up one, down one, or stay at the same height. We then fill the next column to that height.
After we finish going through the sand algorithm, we get the result in the picture.
Next up, we need some seaweed:
Our seafloor is looking pretty nice now. How is the seaweed made?
First, we need to pick where on the sand we want seaweed. We make a list of random columns.
Then, on each column in the list, we grow seaweed.
Simple enough, right?
Oh. You want to know how we make the seaweed. Why didn’t you say so?
The seaweed is created much like the sand is, but going in a vertical direction. We start right above the sand on the column we chose.
Next, we randomly choose if we want to go to the column on our left, on our right, or to stay on the current column. We make that block into seaweed. Then we move up one block.
We continue this process until the seaweed is tall enough, and then stop.
The final step is adding the fish. This picture matches the first picture in the article:
You will notice the fish all look the same. That part of them is actually hand-made. The generated part is where we put them.
The fish are actually created in schools. First, we need to figure out where to create a school. To do this, we pick a random column. Then, we choose a random block near the top of that column.
We then randomly choose several points in the circular area centered around the block. We then put a hand-made fish at each of these points.
There is one last detail. We choose a direction (left or right) at random. We then make all the fish in the school face that direction.
That’s it. The picture is done.
The nice thing about algorithms is that computers can run them. We can generate similar pictures with the same algorithm:
You know, there is something fishy about these pictures…
You get it? Because they have fish?
Anyway, that is how procedural generation works. This is a relatively simple example, but even this lets you see all the cool things you can make with it.
Let’s be honest, though. You aren’t here because you want to learn about algorithms. You just want to see the pretty pictures.
Fair enough. The following pictures are all made using procedural generation:
The only way this picture of volcanoes could get any hotter is if I was in it.
“Back when I was a kid, we had to walk five miles to the school in the snow, and it was uphill both ways! And we liked it that way!” they say. Well, you know what? I had to walk up a mountain. With only one leg. And I liked it that way!
You know, there is less gravity on the moon. If you went there, you would finally lose that weight. Of course, that implies a rocket carrying you could ever lift off.
You got a sandbox? I got a desert.
Let it snow, let it snow, I don’t have a joke for this anyway.
It’s raining, it’s pouring, you are rather boring.