# How to make procedurally generated terrain look realistic

I generated a terrain using a technique from this blog post, everything worked well and I got the wanted result. This is what my generated island looks like: As you can see the terrain have a polygon structure. Here is the graph that generated this mesh: This is the code used to generate this mesh from the graph:

    void DrawPolygons(){
List<Vector3> vertices = new List<Vector3>();
List<int> triangles=new List<int>();
List<Color32> colors = new List<Color32>();

foreach(Center c in centers){
float zp = zScale*c.elevation;
Color c0 = getColor(c);
int centerIndex=vertices.Count-1;
var edges = c.borders;
int lastIndex = 0;
int firstIndex = 0;

for(int i =0;i<c.borders.Count;i++){
if(edges[i].v0 == null && edges[i].v1 == null)
break;

//get voronoi edge
Corner corner0 = edges[i].v0;
Corner corner1 = edges[i].v1;

//get vertices height
float z0 = zScale*corner0.elevation;
float z1 = zScale*corner1.elevation;

if(edges[i].river>0){
c0 = Color.cyan;
}else{
c0 = getColor(c);
}

//creat voronoi edge points
Vector3 v0 = new Vector3(((Vector2)corner0.point).x,z0,((Vector2)corner0.point).y);
Vector3 v1 = new Vector3(((Vector2)corner1.point).x,z1,((Vector2)corner1.point).y);

var i2 = vertices.Count - 1;
var i3 = vertices.Count - 1;

//add triangles calculating surface normals so i can always add triangles clockwise correctly
var surfaceNormal = Vector3.Cross (v0-(new Vector3(((Vector2)c.point).x,zp,((Vector2)c.point).y)), v1-(new Vector3(((Vector2)c.point).x,zp,((Vector2)c.point).y)));
if(surfaceNormal.y>0)
else

firstIndex = i2;
lastIndex = i3;
}
}

//calculating uv's
Vector2[] uvs = new Vector2[vertices.Count];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(vertices[i].x / SIZE, vertices[i].z / SIZE);
}

mesh.Clear();
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();
mesh.uv = uvs;
mesh.colors32 = colors.ToArray();
mesh.RecalculateNormals();
mesh.RecalculateBounds();
meshFilter.sharedMesh = mesh;
meshCollider.sharedMesh = mesh;

}


I would like to know if it's possible to have a noisy/realistic looking terrain from this. How would I implement such a thing?

Basically I want something with no hard edges, terrain that looks smooth but not too smooth, something like this video shows: • Define "noisy/realistic". Jun 25, 2019 at 19:57
• Basically no hard edges, a terrain that looks smooth but not too smooth, something like this Jun 25, 2019 at 20:01
• Use gouraud shading, tessellate mesh and run terrain erosion algorithm. Jun 25, 2019 at 20:04
• Thank you ithink this is exactly what i needed i'm gonna research this now and see what i come up with. Jun 25, 2019 at 20:08
• Check Sebastian Lague on youtube, he has multiple videos on procedural terrain generation. Will help you a lot
– Nick
Jun 26, 2019 at 16:10

First of all, note that Unity already has a very nice terrain system out-of-the-box. It gives you a lot of nice features for free like LOD, occlusion culling and a lot more. Also, it can look pretty neat. You can still generate terrain procedurally, but the input data it expects isn't a mesh but a height map in form of a two-dimensional array of floats. So if you want to keep using that cell-based algorithm, you will have to convert it to output a heightmap instead of a list of vertices.

But no matter which technical implementation you choose to render your map: If you want to generate a landscape which combines discernible large features with small details, then it is usually a good idea to layer multiple terrain generation algorithms on top of each other. Use a pass with a high amplitude and a low resolution to generate the basic shapes (like you already do), and then run another pass with a lower amplitude but a higher resolution to create detail.

You could, for example, apply the same algorithm you are already using again for each cell to subdivide it further. Or you could use a completely different algorithm to "rough up" each cell like Perlin Noise.

Also, don't underestimate the effect of good textures. A high-resolution texture with a good normal map could make a terrain surface look a lot less plastic-like. Keep in mind that you need to also call mesh.RecalculateTangents() on your mesh for normal maps to render correctly.

I am looking forward to exploring the procedurally generated worlds in your game.

• i like the idea of using this to produce a height map to then implement it in the existing unity terrain system but i think that will make me loose the benefits of the graph based terrain generation wich helps me define biomes and maybe even use it for pathfinding later on. For now i will try to add more algorithmes to this like tessalation and different erosion algorithmes and see how it turns out. Jun 26, 2019 at 16:23

A good way to generate realistic terrain is to simulate physical processes like

• corrosion
• either with a "uniform" corrosion algorithm or simulation of water or both
• simulation of interaction of multiple sediment layers, don't forget that the origin of a lot of amazing landscapes are the sediments and the interactions of them with water underneath, like stone, dirt, sand, etc.
• plate tectonics(?) (no idea which game simulates that but it's maybe possible)