How to generate procedural 2d terrain in the style of elevation line maps?

Hey all!

I’m playing around with an idea for a game that would use a 2d map that looks like an elevation line map. My only experience map wise is simple 2d tile based maps where every tile was represented by a different quad. I’ve done procedural generation before so I don’t need any pointers concerning Perlin noise or how that type of thing is used, more the actual generation part of it all. IE, how you take an array of info generated by Perlin noise and turn it into a visual representation.

If anyone knows of any tutorials they could point me toward it would definitely be appreciated!

Most procedural generation builds ‘visual representations’ by applying kind of 3D surface approximation algorithm, like Marching Cubes, and for which this page is a popular, clear explanation. But that won’t generate anything that looks like a topographical line map, so I’m not sure whether it’d really help you.

I think what you’d want to do is something like: for each square and the 8 squares neighboring it, check if there is a change in elevation as you move along any of the 4 lines connecting the cube to its neighbors, and, if so, draw lines connecting cubes in along the line perpendicular to the one along which the change was detected. For small enough cubes, I think something like this would approximate the edges where elevation change occurs.

To smooth out the lines used, you could either use smaller cubes, or draw polynomials or splines rather than lines between the cube centers, although I don’t know how you’d go about making those particular shapes in Unity; for lines, linerenderer seems like a possible native solution.

Thanks for the reply! After some searching around I’m considering working with a mesh, starting to consider the possibility of making the terrain 3d with the same effect.