1
0

1 unit is 1 meter, update black texture

This commit is contained in:
Sky Johnson 2025-09-09 20:59:04 -05:00
parent a2452e3cf6
commit 552cafb2ba
2 changed files with 14 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 637 B

View File

@ -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;
mesh.vertices[idx * 3 + 1] = data[idx];
mesh.vertices[idx * 3 + 2] = (float(z) / (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.texcoords[idx * 2] = static_cast<float>(x) / size;
mesh.texcoords[idx * 2 + 1] = static_cast<float>(z) / size;
mesh.vertices[idx * 3] = worldX;
mesh.vertices[idx * 3 + 1] = data[idx];
mesh.vertices[idx * 3 + 2] = worldZ;
// 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;
}
}