This is a question for the heightmap terrain plugin for Godot 3.2. I don't know if its author @Zylann is around to help with this one, but if anyone has an answer I'd be very grateful.
I'm using the HTerrain node to create a procedurally generated terrain. It's working well with the terrain and splatmap both being generated accordingly! I'm trying to do something a little unusual however: I want the heightmap to be seamless and possible to loop horizontally. The plan is to use renderer portals (will open a thread about those later) in order to make it feel like a tiny planet, where once you reach an edge you come out the other end without noticing the border. For this I need each side and corner of the terrain to connect with the opposite side and corner.
I'm not sure what adjustments I'd need to make to the heightmap generation function to make it seamless, in a form that accounts for the terrain size and resolution. I'm starting from the noise function suggested in the Github docs:
for z in heightmap.get_height():
for x in heightmap.get_width():
# Generate height
var h = noise_multiplier * noise.get_noise_2d(x, z)
# Getting normal by generating extra heights directly from noise,
# so map borders won't have seams in case you stitch them
var h_right = noise_multiplier * noise.get_noise_2d(x + 0.1, z)
var h_forward = noise_multiplier * noise.get_noise_2d(x, z + 0.1)
var normal = Vector3(h - h_right, 0.1, h_forward - h).normalized()
# Generate texture amounts
# Note: the red channel is 1 by default
var splat = splatmap.get_pixel(x, z)
var slope = 4.0 * normal.dot(Vector3.UP) - 2.0
# Sand on the slopes
var sand_amount = clamp(1.0 - slope, 0.0, 1.0)
# Leaves below sea level
var leaves_amount = clamp(0.0 - h, 0.0, 1.0)
splat = splat.linear_interpolate(Color(0,1,0,0), sand_amount)
splat = splat.linear_interpolate(Color(0,0,1,0), leaves_amount)
heightmap.set_pixel(x, z, Color(h, 0, 0))
normalmap.set_pixel(x, z, HTerrainData.encode_normal(normal))
splatmap.set_pixel(x, z, splat)
I could also use help with introducing a seed to represent each random result. As well as better quality looking terrain with proper mountains, currently this only achieves simple random bumps.