## Lemmy’s blog currently down (link to copy of post below)

It looks like traffic killed our site, given that we got a completely unexpectedly large volume – which is great… but then your hosts get grumpy and break your site for you đ So, until Lemmy’s blog is restored or this part of the site also explodes in a fiery mess, you can at least...

## Simple Landscape Generation

### Posted by CaptainBinky | Posted in Stuff | Posted on 26-02-2016

#### 2

Man I love playing around with landscape generators, it’s the most therapeutic thing ever. I recommend it. It’s the weekend tomorrow, what are you waiting for?

Anyway, in a break from whinging about games and the games industry I thought I’d write a few words about some daft experiments I was doing with landscapes… uhhh… (checks date modified on these files)… blimey, was it 2 years ago? Yeah, apparently mid 2014(ish). I had intended to write this blog post then, but it seems I never got around to it đ

Here’s an example of one of the landscapes wot I generated:

A couple of things to note: Firstly, it tiles in both directions which is handy. Secondly, it’s not very Perlin Noise-y. That’s because I didn’t use any kind of noise function to generate it – well, I sort of did (I’ll get to that), but not in the conventional way.

Perlin Noise (or more accurately nowadays, Simplex Noise) is probably the world’s handiest algorithm ever for generating textures. We’ve all seen it, we all know what it is, so there’s no reason to go into it beyond this extremely crude example:

Yeah?Â It’s basically that except not using regular sine-waves, but instead adding together interpolated random noise –Â for every iteration the frequency of the noise goes up and the amount it contributes goes down.Â When using Perlin NoiseÂ to generate your noise values, the result of cumulative additions (each time doubling the frequency and halving the intensity) isÂ that classicÂ turbulence look which is so synonymous with Perlin Noise that we often call the texture itself Perlin Noise:

(Okay, this is Photoshop’s Cloud Filter. But it’s basically the same and, for all I know, might actually be coded using Perlin Noise)

Anyway, I bring this up not because of any of thisÂ specifically, but because the principle it operates on (add together lots of things to build up interesting structured noise) is the principle my landscape generators work on. This principle can generate you really interesting landscapes irrespective of what it is you’re using to add together to produce your final result. So your source could be an unstructured random mess but the act of adding lots of it together – each time the input contributing less than the previous iteration – can produce ordered structure.

So for my landscape, what was my input? Well, I just repeatedly addedÂ sine-wave strips (where each strip’s orientation – either horizontal or vertical – and its position, thickness, amplitude, and frequency were random). So the first iteration would look like this, for example:

And iteration two, could look like this:

Keep going, then render it with landscapey colours and you end up with something like my landscape above. It’sÂ dead simple and you can use absolutely anything for your iterative additions – sine-wave strips, filled circles, filled squares, various pictures of cows – anything. Because anything added together sufficiently, will eventually produce something which looks like structured noise – which makes playing with your inputs kind of fun đ

So – now knowing that my landscape is just lots and lots of sine-strips, looking at it again it’s really really really flupping obvious:

Here’s a landscapeÂ where I used filled circles (with random positions, radii, and strength – where the strength also diminishes with each iteration), where the circles were filled like a crater such that in cross-section they’d look sorta like this:

Notice the crater in the central island đ

So anyway. It’s not rocket science, nor the world’s most amazing way to generate super-realistic landscapes. But it’s fun, so I thought I’d share đ

edit: This is what I love most about playing with this sort of stuff.Â How something actually works isn’t in the least bit important, all that matters is whether the results are close to what you want. I love it when the underlying nuts and bolts are stupidly simple.Â While I don’t claim to have invented anything original with this approach, whatÂ lead me toÂ this style of heightÂ generation was thinking about landscapes in terms of plate structure. IÂ considered trying to simulate plate tectonics (crudely) but then decided that it wasn’t really important how I got these sorts of structures only that I got them. So the sine-wave wibbles wereÂ the first toe-dip into this kind of thing. Instead of using smooth noise, using a pattern with a sharp cut-off (you’re either in the sine-wave ripple (and therefore adding a bit), or you’re not – there’s no interpolation) could yieldÂ some interesting features – a curve of a bay where around that curve you may get some little atolls, or dramatic cliff edges. These little features did somewhat end up in the results – close enough, at least, to be fairly satisfying.