Topic was automatically imported from the old Question2Answer platform.
Asked By
honzah70
I am trying to make “2D” terrain. I discovered that in the Editor you can make a CollisionShape with a HeightMap Shape. With OpenSimplexNoise I managed to edit the HeightMap so that it has some random elevation.
However it only applies to the CollisionShape and I don’t know how I can “link” it with a Mesh so that the Mesh is the same shape as the HeightMap.
I found out that you can make a CollisionShape based on a Mesh. Is there a way to make it the other way around?
Godot does not come with a terrain node to render heightmaps, so you have to script that.
There are several ways to go:
Generate the mesh by code. That is, add every vertex yourself and connect them together to form the mesh. This can be accomplished with SurfaceTool, or just using raw arrays, creating an ArrayMesh and calling add_surface_from_arrays(). See Procedural geometry — Godot Engine (stable) documentation in English
Put heights into a texture, then use a MeshInstance with a subdivided PlaneMesh and displace it according to the texture using a shader. This is a common technique used by many terrain systems. You can see an example of that here (with water but it’s the same idea): Your second 3D shader — Godot Engine (stable) documentation in English