Now Reading
Round The World, Half 1: Continents : Frozen Fractal

Round The World, Half 1: Continents : Frozen Fractal

2023-11-14 07:14:17

There’s this recreation idea that has been on my thoughts for years, and I can’t appear to let it go. You step into the moist, salt-crusted sneakers of the naval explorers of previous: Columbus, Da Gama, Magellan, Prepare dinner. A lot of the world remains to be a giant unknown query mark: right here be dragons. There are not any satellites, no GPS, not even maps. The one solution to discover out what’s out there may be to really go there – which is a dangerous enterprise. Your navigational instruments: a compass, the solar, moon and stars, and any info you may be taught from the locals alongside the best way. Your purpose: to discover a route all over the world and find yourself the place you began.

The prototype

When the tenth Alakajam! recreation jam got here round with the triple theme of “Ships, Maps and Chaos”, I knew I needed to construct a prototype of this recreation. That grew to become Around The World, and it labored. The mixture of map studying, buying and selling, and managing the chance of going on the market with restricted provides turned out to be attention-grabbing.

So a couple of months in the past, I began work on a much bigger recreation primarily based on this idea. I’m nonetheless tentatively calling it Round The World, however the title could change earlier than launch. I can’t promise that I’ll have time to weblog about it each step of the best way, however I’ll attempt.

Procedural era

The actual Earth has been absolutely mapped and explored, so that might make for a boring recreation. I may create a special world by hand, however then the participant would understand it after a couple of playthroughs, which is dangerous for replayability. So I’m turning to the indie recreation developer’s finest good friend: procedural era. Each playthrough, the world will probably be created from scratch by a collection of algorithms.

Within the first instalment of this weblog collection, we’re going to set the stage, and develop an algorithm that creates some continents for us.

A sphere is essentially the most excellent form

The prototype befell on an oblong map, with the left aspect wrapping round to the fitting to type a cylinder. Polar ice caps prevented you from going off the highest or backside. Many video games do that and get away with it, however as a result of I’m a perfectionist, I would like my recreation to happen on an precise sphere.

This could give attention-grabbing gameplay choices: you’ll be able to keep close to the equator, which is the lengthy route, however comparatively protected and you’ll profit from commerce winds – otherwise you go round a pole, which is shorter, however has extra averse climate and icebergs to take care of.

The actual world has infinite decision, however we’re working in a finite pc, so we’ve got to cut back our world to some sort of grid. Sadly, there’s no solution to divide a sphere up right into a grid of equal-sized shapes, like squares, triangles or hexagons. It’s simply mathematically inconceivable. Ultimately, I selected to make use of a quadrilateralized spherical dice as an alternative: six sq. grids within the form of a dice, which is then projected onto the sphere:

Quadrilateralized spherical cube

Nevertheless, there’s a drawback with this mapping. As you’ll be able to see, the squares close to the corners are fairly a bit smaller than the central ones, and far distorted from their true sq. form. Because of this we are able to’t merely assume that every sq. is identical measurement, which can complicate our algorithms.

To mitigate this a bit, we are able to borrow a trick from Google’s S2 library: apply a nonlinear transformation to the coordinates on the dice, earlier than projecting them onto the sphere. The consequence shouldn’t be excellent (it could’t be), however fairly a bit higher (much less bulging):

Quadrilateralized spherical cube

The precise transformation utilized by S2 shouldn’t be documented, however we are able to discover it by studying the source code. I’m utilizing their tangent projection, which is one of the best but additionally the slowest. With out the transformation, nook squares are 5.2 instances smaller in space than heart squares. With the projection, they’re only one.414 instances smaller, which is a sufficiently small distinction that we are able to (and can) ignore it normally. As a result of the projection is a bit sluggish, I calculate it solely as soon as for every cell and retailer the ends in a cache.

Pretend it until you make it

On Earth, our landmasses are made up of tectonic plates, which float round on a layer of molten rock referred to as the mantle. These plate tectonics are the primary driver for large-scale geographical options: continents, islands, mountains, trenches, volcanoes and so forth. So it’s helpful to have a fundamental understanding of how these things works.

Previously, I’ve experimented with truly simulating plate tectonics. It was cool to see all of the continents drifting round on the sphere, however I noticed it was ineffective for this recreation: it gave me, as a recreation designer, little or no management over how the world turned out. To make the sport playable, I’d must set limits corresponding to: have six continents, not too huge or too small, and evenly distributed throughout the globe. A bodily simulation makes it very exhausting to try this, so I made a decision to faux it.

Continent shapes

A standard solution to create random-looking shapes is the Voronoi diagram. Merely generate some random factors, referred to as seeds, and assign one another level to the seed that’s closest to it. Afterwards, we resolve for every seed whether or not this will probably be land or water. Right here’s how that appears on our sphere:

Voronoi diagram on a sphere

Earth has six continents, protecting about 29% of its floor. To match that ratio, I generated 21 Voronoi areas and randomly designated 6 of them to be land (inexperienced).

It’s a begin, however we are able to do higher. The issue with Voronoi areas is that they’re at all times convex, so there can by no means be any indents within the continent shapes. Boring! So what we are able to do is create extra, smaller Voronoi areas, and assign a number of areas to the identical continent. We begin every continent from a single area, then randomly develop it by together with neighboring areas, till we’ve got sufficient land. Right here’s the consequence:

Multiple voronoi regions per continent

Significantly better! These are beginning to seem like believable shapes for our landmasses.

However they’re nonetheless relatively straight and boring. To repair that, we are able to use one other trick from the procedural era ebook: area warping. For every level, as an alternative of instantly searching for its closest Voronoi seed, we first jiggle the purpose a bit. Factors close to these straight boundaries may then get jiggled throughout the boundary, and find yourself being assigned to a different Voronoi area.

Let’s introduce yet one more frequent procgen constructing block: simplex noise. I received’t clarify what simplex noise is right here; in case you don’t know, simply consider it as a magic machine which you could put coordinates of a degree into, and it spits out a random worth between -1 and 1. In case you put the identical level into it once more, you get the identical worth out; and in case your level is barely totally different, you’ll get a barely totally different output worth.

To do that “jiggling” of factors then, we are able to create three situations of simplex noise, one for every of the x, y and z elements. To every level we add a small quantity of this noise earlier than assigning it to its closest Voronoi area. This has the impact of breaking apart the straight strains:

Domain warped Voronoi

See Also

These could be some nice continent shapes to discover! Word that the area warp typically causes bits of Voronoi areas to type an “enclave” inside one other area. These are literally inland oceans (very deep), however they seem like lakes, so I didn’t hassle eradicating them.

Scaling the heights

To this point, all our land is completely flat. Boring! This virtually screams for extra simplex noise to be added:

Heights using simplex noise

Wanting higher! Discover that I’m utilizing color to characterize peak right here, so e.g. yellow doesn’t imply “desert”, it means “about 800 meters above sea degree”. The color ramp resembles the one used on this map from NOAA, so I can simply examine how comparable my world is already wanting:

NOAA height map

that peak map of the true world, I seen that heights have a tendency so slope downwards to the coast, relatively than ending in 1 km excessive cliffs like in my generated world. In actual life, that is brought on by erosion, however that’s one other tough to simulate course of that doesn’t provide us a lot management. So let’s once more faux it, by making use of a curve:

Height curve

Each a part of the land inside a ways from the coast has its peak multiplied by this curve:

Heights with slopes

Already higher! But it surely appears to be like a bit bland and uniform. Time for extra simplex noise! On this case, I’m utilizing the noise to vary the space over which the curve is utilized. A small distance ends in a steeper, extra cliff-like coast, a big distance in a flatter coast:

Heights with noisy slopes

We’re off to a great begin. Within the subsequent put up, we’ll sort out tectonic plates and their results on the geography of our little world.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top