One of the first 3d graphics programs I tried way back when was the Persistence of Vision raytracer. POV-Ray really appealed to me since I was a hard-core programmer and not much of an artist. I could make high-quality graphics, even though I could barely draw tolerable stick-figures. I’ve since moved on to using more advanced programs such as 3d Studio, but the idea of creating art with pure code has never left me.
Recently, I’ve spent some time playing Minecraft, which generates unique randomized worlds that are created on the fly and are virtually infinite in extent. By using properly designed procedural algorithms, Minecraft creates a surface world of plains, mountains, and oceans populated by trees, plants, and villages with elaborate cave systems below. Granted, the worlds are still very blocky and simple, but the variety is still pretty amazing. One of my more ambitious projects is to extend this idea beyond blocky voxel worlds, and be able to create a full 3d world completely procedural.
“And God said ‘Let there be light!'” … *Click*
I recently started on the first step of this journey. You can’t have a world without ground, so for the past few months, I’ve been working on a procedural landscape generator. I already had modules for handling geometry meshes, so I just needed a method for creating procedural heightmaps. It’s easy enough to iterate over the vertices in a high resolution plane, and set the height as a function of the vertex’s x and y coordinates. However, I didn’t want to limit the landscape to a set of pre-canned functions. I wanted to be able to make whatever landscape I could think of without needed to add new equations to the program and re-compile it every time I had a new idea.
The Genesis Machine
The solution I decided on was to parse a Lisp-style domain specific language into opcodes and use a custom-built virtual machine to execute the landscape heightmap function. This was my first experience with virtual machine programming, and it was very enlightening. In future posts, I’ll describe the pieces of this prototype landscape generator. But in the meantime, here are a few samples of what it’s capable of right now.