This is a simple demonstration of how to extend my limitless terrain generator to a spherical surface, such as a planet.

My original technique, on a limitless plane, is explained in the document "TerrainGeneration.pdf" which you can download below. It includes information about generating terrain on a sphere.

The key thing about extending to spherical surfaces is NOT to use latitude and longitude as the parameters for the generating function. The reason is that that coordinate system becomes ambiguous at the poles. The latitude there is +/-90 degrees but the longitude can have any value. As you approach the pole along different lines of longitude you will get different values for any function based on those 2 coordinates.

To make a map centred on any lat/long position you need first to find the Cartesian coordinates of that position relative to the centre of the sphere and then use those x, y and z values for the calculation. All 3 values change smoothly at the poles, as elsewhere, so there is never any singularity. The contour map on the right here is looking down on the north pole of a planet.

In my demonstration I have used an orthographic map projection, onto a plane tangential to the surface, and drawn contours using Bourke's algorithm (using some of my code from The Forest). You can vary the radius of the planet and the position of the centre of the map.

I am making the source code available. It is simple HTML5/Javascript using only the 2D canvas API. Feel free to use it, extend it and adapt it to other programming systems.

Update 26/1/23 shows colours for various terrain types on the map, not just height contours as before. Also in the source you could change a boolean to enable recording a faster video of the rotation (using standard Windows 10/11 screen recording).

Update 23/12/22 has planet rotating.

Update 18/5/22 allows the sea level to be adjusted.

Update 19/4/2022 has a sea level. Brown contours above that level, blue contours below. So there are seas/lakes and continents/islands.

Updated 21 days ago
StatusReleased
CategoryOther
PlatformsHTML5
Rating
Rated 4.0 out of 5 stars
(3 total ratings)
Authorgrelf
Tags3D, Procedural Generation, technique

Download

Download
Source code 6.5 kB
Download
TerrainGeneration.pdf 4.5 MB

Comments

Log in with itch.io to leave a comment.

this is cool to play with !