Godot Version
4.6.beta
Question
No compute shader tag available
Hi,
I’m playing around with procedural generation, including diving into compute shaders. My basic idea is to take various plane meshes, generate heightmaps, and apply those heightmaps to the planes that are laid out in a grid. I’ve managed to make the heightmap itself seamless - the edges of the tiles look like they are continuations of each other - but there’s a literal, physical line between each of them.
Zooming in, it seems that the “higher” mesh is always a little higher along the edges, the “lower” mesh always a little lower:
I’m trying to bridge those little gaps, somehow. I tried extending the dimensions for what is drawn, but the problem persists - they just overlap with each other in a noticeable fashion. Looking at it from directly above, it seems they match up in X and Z coordinates (all visible distances are from shadows), so I assume it’s something about how my height is applied.
Here is some of my GLSL code for how heightmaps are applied (cutting out non-height-related calculations):
#[compute]
#version 460
layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in;
layout(r32f, binding = 0) uniform readonly image2D heightmap;
layout(set = 0, binding = 1, std430) buffer Vertices {
vec4 data[];
} vertices;
layout(push_constant, std430) uniform Params {
float dimension;
float resolution;
} params;
float get_height(float x, float y) {
float u = (x / params.dimension + 0.5) * (params.dimension - 0.5);
float v = (y / params.dimension + 0.5) * (params.dimension - 0.5);
ivec2 coord = ivec2(u, v);
return imageLoad(heightmap, coord).r;
}
void main() {
uint gid = gl_GlobalInvocationID.x;
vec3 vertex = vertices.data[gid].xyz;
vertices.data[gid].y = get_height(vertex.x, vertex.z);
}
Do you see if there’s an obvious error that’s causing this slight offset?


