Monday, October 12, 2009

Perlin simplex noise

I'm now working on my lunar lander program again. The core idea is to adapt Thrust gameplay for a circular planet, so that orbiting is a possibility. My goal is to release something in early December.

The top priority is to get an interesting planet to land on. I am working from these sources, albeit translating everything into two dimensions:
The basic idea I'm trying out is to define a density function over the plane, and then evaluate it to find the boundary where density crosses from negative to positive. The density function can be built up out of a variety of pieces; at the moment I'm starting with a radial increase with an offset (d = r - 1):

Layered on top of that are several octaves of Perlin's simplex noise. The first two are shown below:

I convert the implicit function to a surface by subdividing a large triangle that encompasses the planet; you can see its outline (cropped by the window rectangle) in the pictures above.

Below are the results of layering the radius function with three octaves of noise:

There are lots of other things to try; this is as far as I got last night.

The next step is to build a BSP or spatial hash in order to make the terrain solid. That should not be hard. After that I will probably want to triangulate the interior and texture it; I'm still thinking about the best way to accomplish that.

The noise functions don't guarantee that everything will be interconnected. You can see free-floating bits, as well as isolated pockets of air inside the ground. It might be nice to filter out the isolated pockets, and maybe justify the floating junks of rock by rendering a background layer to suggest that it's the cross section of an arch.


Mingos said...

Hey, simplex noise is a great alternative to the traditional Perlin noise, as it's way faster, although in your case the difference might be negligible.

If you plan to go for the 2D look presented on the images, a floodfill will do the trick, especially if you only mark the densities as true/false.

You may also consider alternative ways of generating the planet. Tracing a circle with a variable radius might be a possibility, although the surface's look will be very different and perhaps not what you're aiming at.

kometbomb said...

This looks great. I have been working on a roguelike gravity game and came up with something very similar looking (marching squares combined with particles with different types, minerals, sand and such, that settle towards each other). This way it's easy to fill the insides. I just use null particles to create caves. You could in theory link the null particles together to create longer caves that are guaranteed to be connected.

I render it back to differently shaped tiles, though, so it makes collisions simple.

Very interesting project. :)

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Philippe Da Silva said...


I'm currently googling the web to find out how I could generate seamless simplex noise textures.
Since you seem to get a good experience with noise, could you please give me some clues as Google didn't save me this time :p


Philippe Da Silva
philippe dot dasilva at me dot com