# Non-GPU Noise for 2D side-view terrain generation?

I really couldn't find a correct answer while scowering all the forums for Noise Generation.

My goal is simple, I really want to have two distinct layers for my terrain, a white layer representing air, and a black layer representing earth. An algorithm will pick up from there.

Most noise I found generated "Cloudy" textures, where I am looking for something along the lines of:

So far I have worked with Perlin Noise but adjusting my values yields no useful results.

Does anyone have any ideas?

You probably want 1D Perlin noise instead of 2D for this. Treat the noise function as defining the height of the terrain at each column, and fill everything above that height with white and everything below with black.

• I was just researching that. for some reason I can't wrap my head around 1D Vs 2D Perlin Noise.
– Ross
Jan 10, 2012 at 4:46
• @Ross You can just think of it as a noise function that takes either one or two (or really any number of) parameters and varies pseudorandomly based on all of them. Since you only need random variation based on the horizontal position, you only need 1D in this case. If you have a 2D noise function you can just set the second parameter to any constant value. Actually, setting the second parameter to different values would generate different maps, so 2D noise would still be useful for you if you want to generate multiple maps. Jan 10, 2012 at 20:19
• Although, 1D noise would not produce any overhangs (which the OP has about a one pixel overhang in the example image, perhaps that's not intentional?). It would be a simple way to get started and overhangs could be added later with additional noise blending. Jan 10, 2012 at 23:54

Local minima and maxima

Randomize a set of float numbers from 0 to 1.0 (exclusive), denoting position along the x-axis. Do this once, and call these minima (they sit below the baseline). Do this again, and call these maxima (they sit above the baseline). Push each minimum down by a random amount. Push each maximum up by a random amount. Now merge the two sets into a single set, and sort by increasing x. Then join the points in order of increasing x. You could use lines, or some curve function if you want it more organic. There's your random terrain.

Sine-wave mashup

This alternative which might (a) be simpler to implement than Perlin noise, if somewhat more brute-force in nature, and (b) might simultaneously open your eyes as to how simple the 1D Perlin noise solution Nathan's explaining, is.

Consider a sine wave. It roughly approximates what you have in your diagram, except it's too smooth and regular.

You can generate a bunch of random sine waves. By random I mean, with random amplitudes, random frequencies, and random offsets from the origin. Then merge them. Then take only the uppermost (or lowermost) part of the combined wave functions. Then smooth the result. Now you should have some sort of an organic but irregular surface. TBH this is something of an oversimplification, and there are mathematically far better ways to merge/smooth, but you get the general idea.

This is exactly what 1D Perlin noise is. All you're doing is taking a cross-section through the noise plane that Perlin produces. Perlin noise is just a set of overlaid/merged waves which have random frequencies, amplitudes, and offsets (all of which are within user-specified ranges, being the parameters you pass to the Perlin noise function), and which operates in 2 or 3 dimensions.

So you can take either approach, and you'll get something like what you want. I'd still suggest using Perlin though, as there are no question marks there. It's a given that it'll work the way you want.

I wouldn't use noise for that.

Have a look here : http://thegoldenmule.com/blog/?p=80 for 2 different algorithms to create Scorched Earth like terrain like you seem to want.