diff --git a/meshers/blocky/terrain_2d_mesher_blocky.cpp b/meshers/blocky/terrain_2d_mesher_blocky.cpp index 7386312..d4e815a 100644 --- a/meshers/blocky/terrain_2d_mesher_blocky.cpp +++ b/meshers/blocky/terrain_2d_mesher_blocky.cpp @@ -154,12 +154,22 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref chunk) { } Vector2 uvs[] = { - surface->transform_uv_scaled(Vector2(0, 0), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(1, 0), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(0, 1), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(1, 1), x % texture_scale, y % texture_scale, texture_scale) + Vector2(0, 0), + Vector2(1, 0), + Vector2(0, 1), + Vector2(1, 1) }; + if (texture_scale <= 1) { + for (int i = 0; i < 4; ++i) { + uvs[i] = surface->transform_uv_scaled(uvs[i], x % texture_scale, y % texture_scale, texture_scale); + } + } else { + for (int i = 0; i < 4; ++i) { + uvs[i] = surface->transform_uv(uvs[i]); + } + } + Vector2 verts_normal[] = { Vector2(0, 0), Vector2(cell_size_x, 0),