Hello world!

August 22nd, 2009
Part of the series: Terrain Generator»

This is a new blogroll, obviously, but what we’re going for here is a community site geared towards programmers, gamers, and technophiles.  Or just those curious about that sort of thing.  We’ll generally cover a lot of different topics, from a lot of different people… but it’s all opinion, and open for discussion.  We’d love to hear from you, so don’t hesitate to comment or shoot any of us an email.

So, let’s start things off with a bang, shall we?

First off, for those of you who don’t know me, my name is Luke Pederson and I’m a student at Full Sail University.  Avid gamer and programmer.  Lately I’ve gotten an itch for all things procedural (things which are generated with math rather than stored).   So I wrote a terrain generator*.  This uses a technique called Perlin Noise to generate a height map, which then is used to form dynamic geometry.  In the current build, it’s all done on the CPU, which is expensive to generate, and near impossible to stream terrain generated from there.

From this generated terrain I took the height, and a pseudo-random variance to place textures on the different heights.  So I have a smooth fade from grass to dirt to snow depending on how high the terrain is at a given location.  I spent most of my time optimizing my code, making sure normal averaging wasn’t slow as mud, taking my generation code from about 6 separate double for loops to just two, and drawing the terrain as a single triangle strip rather than 80,000 triangles one at a time (it’s still 80,000 triangles, but the GPU just does it all now in one go).

So my goal from here is to make the terrain more varied and believable, give it virtually no limits, allow on-the-fly modification, and file output.  The first bit means improving the texture mapping (taking into account slope, using more textures, etc), adding sprites so it’s more than just ground, and allowing for peaks, cliffs, and ravines.  Virtually no limit is possible through streaming terrain, but as I said before, it’s currently generated on the CPU, which is slow for this.  So this means exporting the generation to the graphics processor, having it generate the height maps, and then reducing the triangle count for far away geometry.  On-the-fly modification means I’ll need to build an interface for my algorithm so I can create terrain more pertinent to a given situation.   File output goes hand in hand with an interface, but show cases the power of procedurally generated content.  A file telling my algorithm how to re-create a limitless terrain could be as small as a single kilobyte, probably much less.  All I have to keep track of is my seed numbers (random numbers generated once to create new terrain from), my hard limits (height, change in height, cell size, etc), and any little tweaks I might make from the base algorithm.

So, as I start down this laundry list of features, I’ll chronicle my journey here, and hopefully I’ll be able to help those who try to follow in my footsteps, or use it as reference in the future.

* This may require the C++ Runtime (x86) to work and has not been tested on many machines.

Zilchius OpenGL, Procedural Generation, Programming , , , , , , , ,

  • kramen
    @ Zilchius. this is kramen1 (twitter)- i want to work with someone who does coding for iPhone apps. we have a couple projects to get started on. email me kramen@gmail.com for more details if ur or any of ur friends wud like to work on this with us.
  • Zilchius
    @Gazz The drawback of processor power is usually a one shot thing. You'll see it in the loading time when the computer generates, or unpacks all of the data you're about to see. The content can also be generated at runtime, but you're going to see a major performance hit if it’s more than just one or two things.

    I am familiar with .kkrieger, and would agree that it's sort of a novelty rather than an example of a full featured game. But it shows the truly impressive nature of procedural generation in its ability to make compact files. Two prime examples of procedural content in a commercial title are Spore and FUEL, though many other titles use the technique.

    Spore uses procedural content for the textures, animations, and overall personality of the creatures you create. It's the only way they could allow you to feel like you've actually created your own creature here, and takes away any limit that might be caused by designers or artists trying to create that content for all the different types of creatures you could create (never mind that it would probably be impossible for them to do within their own lifetime).

    FUEL on the other hand uses it much in the same way I am here, to generate terrain. Their game has 14,000 square kilometers of play area, which consists of a number of unique areas inside of it. They almost let you drive as far as you want in any direction, and it will take literally 2 hours to get from one corner of the map to the other. The trick here is that each zone has its own algorithm to generate that particular area, and then an artist can go in and add a couple of unique spots to this area (such as a base camp). But I believe all of the terrain, trees, roads, and random buildings are procedurally generated, if not also the races themselves.

    Obviously both of these are scalable and will take work off of the artists so that they may work on getting more details into the game. While neither game is exceptionally popular, they show that this technique is used in the industry. In fact, the forests in Oblivion are procedural as well, made to mimic how forests actually grow, taking into account erosion and such forth. This is more often the use of the technique, being as that once again, building a forest by hand is time consuming and a waste of an artist.

    If you're interested in seeing more, I've found a list of full motion videos that are procedurally generated here: http://www.pouet.net/prodlist.php?order=views
  • Gazz
    I've heard very little about procedural generation, is its only major drawback the processing power it requires? I heard quite some time ago about Synth (http://www.greatgamesexperiment.com/game/synth) through Rock, Paper, Shotgun, which prompted me to look into the idea and find .kkrieger (http://www.theprodukkt.com/kkrieger). Both of these take advantage of procedural generation in different ways, but at the time it struck me as an interesting novelty at nothing more.
blog comments powered by Disqus