how can I smooth a mesh in vertex shader

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

Im working on a clipmap terrain in godot 4 and im trying to get rid of this weird stepping effect in the terrain. How can i smooth my terrain and get rid of this stepping.

Godot 6 Clipmap Terrain Stepping

I think the issue is probably in my vertex shader but im not sure where.

shader_type spatial;

global uniform sampler2D heightmap : repeat_disable;
global uniform sampler2D normalmap : repeat_disable;
global uniform sampler2D texturemap : repeat_disable;
global uniform float amplitude;
global uniform int scale;

varying vec2 texture_position;
varying vec4 heightmap_texture;

void vertex(){
vec3 world_vertex = VERTEX + MODEL_MATRIX[3].xyz;
texture_position = (world_vertex.xz + float((textureSize(heightmap,scale).x / 2))) /float(textureSize(heightmap,scale).x);
heightmap_texture = texture(heightmap,texture_position);
VERTEX.y += mix(0.0, amplitude, heightmap_texture.r);
}

void fragment() {
NORMAL_MAP = texture(normalmap,texture_position).rgb;
ALBEDO = texture(texturemap, texture_position).rgb;
}