Planet GeneratorPosted: September 6, 2011
Sketches have a way of growing old when you don’t touch them for a couple weeks. Aug06 is a random planet generator that I worked on pretty furiously for about four days, and then promptly got bored of. It seems that the more you work on a project, the more you become interested in it, and also that the less you work on a project the less you become interested :P. Anyways, here’s a basic outline of what happened:
First draft. Map a 2D Perlin noise grid onto the sphere. I made a wrapping error by saying the elevation angle should wrap around from PI/2 -PI/2 (which is why all of the lines go towards the bottom center point).
Added plane-drawing and colors based on height. This image shows the major issue that this sketch faced: working in a spherical geometry space. The 2D Perlin noise field produces different heights for different multiples of two pi, thus creating that abrupt line. Also apparent is the squishing of the rectangular projection near the pole of the planet.
It’s an alien planet! LOL. My halfbaked puns will destroy you. This also shows that Perlin noise is an even function, hence unwanted symmetry.
After a rethinking of the underlying mechanism, the planet’s starting to look like an actual planet. The coloring is now a nice gradient; I superimposed several Perlin noises of different time/height scales for a more natural look. I got rid of the Perlin problems by a) adding an offset to the parameters so that there was no symmetry, and b) writing a “smooth” method that basically Gaussian blurs all of the heights. The basic outline for creating a planet is to generate a height map based of Perlin noises and then turn everything below a certain height into ocean, creating semi-realistic looking seas/lakes.
I actually wasn’t originally sure how this planet got to be so swirly, but it looks good. Also, it’s amazing what a simple call to lights() will do to a sketch.
The swirliness was caused by a bug in my smooth method, which actually turned out kinda nice. Definitely gives you pretty unique looking planets.
Replaced the Perlin noise with Simplex noise, which tends to be much more hilly and “regular”. This planet was such a fuck that I just had to include it :P
Floating green squash generator! I started adding terrain features such as hills and mountains, but got one of the coordinates wrong. Also added the starry background + sun which looks quite nice.
Added a coloring method that takes a look at the slopes of various places and tries to color them differently. My goal was to make cliffs look worn out and rocky instead of nice and green. It didn’t really work. I added huge crater features in combination with the Simplex noise and lots of small pokey mountains to get… some evil alien meteor. I really started to lose hope of this sketch ever looking the way I wanted it to.
Plateaus. Change. Everything. Early on I added the ability to render the map in a rectangular coordinates as to help debug various rendering bugs, but this image was particularly pleasing since it has many “nice” features – nice terrain and interplay between the land and the ocean (particularly with regards to those little pointy mountains), multiple levels of terrain with the plateaus, and good coloring (the cliffs actually look yellow, and the very top of the mountain is capped with snow).
Now THAT was what I was looking for. It definitely looks a little cartoony (actually it reminds me of the planets in Spore) but the features are there. I like the way the shoreline looks, especially with regards to that half-white half-blue tone near the center of the image implying a nice shallow pool area. The cliffs also stand out quite nicely.
I wondered what would happen if I took a bitmap image and made a heightmap and colormap out of the pixels. I took my desktop background, a screenshot of the gorgeous multiscale turing pattern, and mapped each pixel’s brightness into a corresponding height point on the planet and each pixel’s color into a color point (obviously). The result wasn’t as beautiful and awe-inspiring as I had hoped but I’m still quite pleased with it. You can make out the valleys and larger features.
Added primitive tree textures; also abstracted out the rendering to let any arbitrary coordinate system draw the heightmap (e.g. into torodial coordinates, as shown).
See the sketch here.
I actually wrote a simple framework with which to easily populate the world with “things” – e.g. plants and animals, man-made features like towers or little villages, flocks of birds, giant turtles, clouds, floating land masses, moons, etc. Unfortunately I never got the time to actually IMPLEMENT all of those ideas. Perhaps I’ll come back to the code later on and give my planets some life.
One thing that really bothers me is that I never fixed the rectangular -> spherical projection problem. There is no perfect way to project a rectangle onto the surface of a sphere, which creates a bunch of issues. What I’d really like is some way to be able to tile the surface of the sphere regularly; perhaps with hexagons or triangles. But this is a whole other field that deserves its own sketch entirely…