Generating Terrain with Perlin Noise
By Dennis Li
- Procedurally generate a world.
- Have it be "infinite."
- Have some sort of interactive player aspect.
Research and Implementation
- First I had to see how a cohesive world could be algorithmically generated. This led me to look at Perlin noise.
- The next goal was to make it look kind of nice, and that involved layering multiple different samples of the noise on top of each other and exponentiating that.
- I was inspiried by a web article to use noise to simulate climate, and so the world is colored procedurally as well.
- To have the program render smoothly, it has a view frustrum which doesn't extend all the way to the world's border. This also has the nice side effect of making the world seem to stream in.
- The interactive aspect is done by allowing the user to move around to view different parts of the world.
- The world is loaded in as different blocks. As you move more than a block's length in any one direction, the furthest edge of blocks are dropped, the whole world is shifted, and the opposite edge is loaded in. This theoretically saves on memory and keeps the computer from buckling after moving far from the origin.
Next Step Improvements
- Provide collision detection so that there is a stronger interactive aspect to the program.
- Investigate threading implementation. Currently after moving aggresively towards the "corner" of the world plane for a while, sometimes blocks get dropped from the world and there is just a giant hole. There are plenty of safeguards to ensure the world waits for the block to finish loading but it still happens on occasion.
- Refactor the Block class to make it easier to have features connect between them. At the moment, blocks and climate only go cleanly between block boundaries because Perlin noise is coherent, but it's not particularly easy to assign say a river to exist between two blocks.
- Add objects into the world. The world is just empty terrain, so it's fairly boring.
- Maybe write this is Java. I'm more familiar with Java and I don't have enough experience with C++ to use any of the features so I end up just writing C in .cpp files. The program would probably be a lot better organized in Java.