Ridge showing up in terrain mesh generated with Simplexnoise

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Momo8289

I’ve been experimenting with generating terrain using a MeshInstance and the simplexnoise. It seems to be working fairly well, however no matter what noise I generate, there is always this rut/ridge thing generated in the middle of the mesh. I’ve edited the parameters a bit to make it more visible, but it’s there no matter what they are
enter image description here

It’s clearly visible, even with more extreme terrain
enter image description here
enter image description here
The fact that it’s there no matter what I do leads me to belive that it’s a problem caused by my code that changes the vertex heights. I’m pretty new to using meshes, so I would not be surprised. This is my code:

func reload_mesh_points():
print("Reloading mesh points")
var mesh = ArrayMesh.new()
var base = PlaneMesh.new()
base.subdivide_depth = division_depth
base.subdivide_width = division_width
base.size = plane_size
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, base.get_mesh_arrays())
var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0)
var row = 0
var mesh_len = division_width + 1

for i in range(mdt.get_vertex_count()):
	print(i % mesh_len)
	var noise_sample = noise.get_noise_2d((row * noise_frequency) + noise_offset.y, ((i % mesh_len) * noise_frequency) + noise_offset.x)
	if i % mesh_len == 0:
		row += 1

	var vertex = mdt.get_vertex(i)
	var vnorm = mdt.get_vertex_normal(i)
	if randomize_vertexes:
		vertex += vnorm.normalized() * rng.randf_range(randomize_min, randomize_max)
	elif use_noise:
		vertex += vnorm.normalized() * noise_sample * noise_amplifier
	else:	
		vertex += vnorm * multiplier
	mdt.set_vertex(i, vertex)
mesh.surface_remove(0)
mdt.commit_to_surface(mesh)
self.set_mesh(mesh)

Any help as to how to get rid of this ridge is greatly appreciated.

:bust_in_silhouette: Reply From: pioenisgreat

Hi,

Maybe you’ve already fixed it, but I think the problem may arise from using ‘i % mesh_len’ here.

Alternatively, you could get the location of the current vertex and use that to sample the noise