- Edited
I have a terrain generator that works fine with a map resolution (multiplicand of subdivisions) of 1, but when I increase it, the map becomes distorted and stops tiling correctly. Examples below.
Resolution of 1:

Resolution of 2:


I've spent time going through the code to make sure the equations are right, and it seems so to me, so I'm a bit lost as to what the issue is.
func _ready():
var circumference = chunk_width * num_chunks * mesh_resolution
var radius = circumference / (2 * PI)
var angle_step = 360.0 / (chunk_width * num_chunks * mesh_resolution)
for segment in range(0, num_chunks):
var plane_mesh = generate_plane_mesh()
var surface = SurfaceTool.new()
var data = MeshDataTool.new()
surface.create_from(plane_mesh, 0)
var array_mesh = surface.commit()
data.create_from_surface(array_mesh, 0)
for i in range(data.get_vertex_count()):
var vertex = data.get_vertex(i)
vertex.y = noise.get_noise_3d(
radius * cos(deg_to_rad(((segment * chunk_width * mesh_resolution) + vertex.x) * angle_step)),
radius * sin(deg_to_rad(((segment * chunk_width * mesh_resolution) + vertex.x) * angle_step)),
vertex.z
) * 5
data.set_vertex(i, vertex)
array_mesh.clear_surfaces()
data.commit_to_surface(array_mesh)
surface.begin(Mesh.PRIMITIVE_TRIANGLES)
surface.create_from(array_mesh, 0)
surface.generate_normals()
meshes.append(MeshInstance3D.new())
meshes[segment].mesh = surface.commit()
meshes[segment].create_trimesh_collision()
meshes[segment].cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
add_child(meshes[segment])
meshes[segment].translate(Vector3(chunk_width * segment + (chunk_width / 2), 0, 0))



