2d height map like Terraria

Hello! I’m working on creating a tile engine in monogame, which seems to be working well. I was just wondering if anybody knew any tutorials about generating height maps to get a “cross section” of a world like they do in Terraria. I’ve seen some information about top down noise maps, but I’m not totally sure how to apply that in this context, and I’ve seen some tutorials of how to achieve this in Unity, but I’d like to do it from scratch. Thanks!

You may think about it more complicated as it actually is. It’s still just a noise function, where you interpret the values differently.

take x/y as your map to get a noise value (where y is vertically). You then just fade to 0 when y > 0 (overground) and fading to 1 when y < 0 (underground) … that’s just the basics

different values of y can give you different types of underground material etc - you still have a noise for the variation

Sorry but I’m kind of new to understanding noise functions. Do you know if there are any good tutorials that could lead me in the right direction? I got it working with just random noise, but I’m not sure how to apply a function to it in order to smoothen it out.

You could have a look at this. It might be a bit complicated. It would be basically what you are looking for. its also a library for generating complex noise.
link its in c++, but there is a C# port

even if you don’t want to mess around with extra libraries, it might provide some insight how you can clamp values of noise and layer them together.

There is a lot of information out there about that sort of thing, you just need to know what to look for. Its not just one algorithm, its multiple things combined to create the pockets and caves amd biomes.


This pdf contains a thorough overview of many techniques involved. Its broad but not very detailed but you can google the names of the concepts to find out much more.

good luck!