Sick weekend: terrain generation

This weekend I’m sick and it sucks. As good a time as any to try myself at terrain generation.

I’m a lousy programmer and it’s the first time I ever dabble with this but here’s the thought process I went through.
Also, It’s not finished, but I figured I’d give myself a motivational boost!

The first step was for me to draw a grid and use the vertices’ coordinates to create triangles. Triangles are then combined into a single mesh.

  • The lines and yellow handles are just there as visual guides.
  • I used coroutines to show the processes step by step (useful for debugging and to make fancy gifs)
  • The two pics below show some various steps in the work. I gradually simplified things and replaced coroutines with methods to go faster.



Up to this point I was adding height noise with a basic Random.Range but switched to Perlin noise to create the terrain-like topography . Thanks Mr.Perlin! <3
I rounded the height values to int to achieve the “ground ladder” effect.


Then some fanciness. I created a basic texture with the terrain color and figured out a basic algorithm to match the mesh’s vertices uvs to the texture.


By far this was the most painful and not funny bit. And my algorithm sucks.

  • I need to remove the “spiky color corners” (tech-savvy language FTW)
  • I need to figure out how flat shading works to make this look appropriately old-school


I also added an arbitrary water plane.


Same thing with noise not rounded to int.


Quick note/question:

I’m quickly limited in mesh vertices count. The limit is set at 65000 meaning that a 275*275 units terrain is already out of bounds. I guess the way to fix this is to generate the terrain data and when creating the mesh, switch to a new mesh when the vertex cap is reached?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>