Generation of a moon terrain

I am making a small game like Kerbal Space Program. What I do is when I am over a certain height, I render the planet or moon as a sphere. Each planet or moon will have a generation seed to generate the terrain when I am going to land. This works really well with an earth like planet.

To generate a surface map for an earthlike planet, I just use 3d rotation to see where the point on the map is in a 3d coordinate space, and take its perlin noise value as height (I also use other factors to see what the terrain looks like, but I just start with a height).

This gives me a beautiful mountain, hill kind of landscape, which works good for watery planets. However, moons and rocky planet terrains have a lot of craters & I have no idea how I am going to do with noise.

Also I am using noise so I wouldn't have to save an entire terrain by itself for a celestial body's surface, I use it so I can see where I am on the planet, and generate the height from there. If there are other solutions please tell.

Instead of using a noise, use an algorithm, that creates the terrain.

You should create every point first at a uniform height, then with a seeded random you pick a position and a radius. After you picked the point, go through every point and if the distance between this point and the center is less than or equal to the radius, then it's in the crater, if it's isn't, then just leave it alone.

For every point like this set the height of it to the minimum of the uniform height minus (x + radius) * (x - radius) / z where x is the distance from the middle point and z is just an arbitary value (A larger value of z mean shallower crates) and the current height of the point (in case a different crater already modified it).

The formula (x - a) * (x - b) is the short version of a quadratic formula, where a and b are the zero points of the quadratic curve.

This way you get some inverse bubble like craters. You could add some random noise to the heights if you want it to look less hand-made.

As @DMGregory pointed out, this is probably just a variation of the Worley noise (a noise where the distance is from the closest point is used) with a max effect radius.

• jsfiddle.net/upueafbt/2 – Bálint May 8 '17 at 21:35
• The algorithm you describe is still a form of noise, specifically a variation on Worley Noise, which is a family of methods that use the distance to randomly scattered points as a basis. – DMGregory May 8 '17 at 21:39
• @DMGregory You're right, let me fix it. – Bálint May 9 '17 at 5:08