diff --git a/assets/textures/black.png b/assets/textures/black.png index adf5e6f..a5a9f24 100644 Binary files a/assets/textures/black.png and b/assets/textures/black.png differ diff --git a/client/main.cpp b/client/main.cpp index 15df7e7..f389df7 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -64,12 +64,22 @@ struct Heightmap { for (int z = 0; z < size; z++) { for (int x = 0; x < size; x++) { int idx = z * size + x; - mesh.vertices[idx * 3] = (float(x) / (size - 1) - 0.5f) * WORLD_SIZE; + // World position in units (meters) + float worldX = (float(x) / (size - 1) - 0.5f) * WORLD_SIZE; + float worldZ = (float(z) / (size - 1) - 0.5f) * WORLD_SIZE; + + mesh.vertices[idx * 3] = worldX; mesh.vertices[idx * 3 + 1] = data[idx]; - mesh.vertices[idx * 3 + 2] = (float(z) / (size - 1) - 0.5f) * WORLD_SIZE; + mesh.vertices[idx * 3 + 2] = worldZ; - mesh.texcoords[idx * 2] = static_cast(x) / size; - mesh.texcoords[idx * 2 + 1] = static_cast(z) / size; + // Texture coordinates: 1 unit = 1 texture tile + // Since world goes from -50 to +50, we need to map accordingly + // Adding 0.5f * WORLD_SIZE to shift from [-50, 50] to [0, 100] + float texU = (worldX + 0.5f * WORLD_SIZE); + float texV = (worldZ + 0.5f * WORLD_SIZE); + + mesh.texcoords[idx * 2] = texU; + mesh.texcoords[idx * 2 + 1] = texV; } }