summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-08 16:23:12 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-08 16:23:12 +0200
commitae574bae0796171b3148d8cbc4ccd869a6f1e63a (patch)
treed300cf9c29690a137d5a07c952838608c0dc2825
parent61136517c7dce8559634446e35cb3629cd40dcb9 (diff)
fix +2 roof clipping below +1 wall
-rw-r--r--src/camera-offset.cpp3
-rw-r--r--src/chunk-render.cpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp
index f7cf23a4..959fe4d5 100644
--- a/src/camera-offset.cpp
+++ b/src/camera-offset.cpp
@@ -16,7 +16,8 @@ with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, chun
auto len_x = (float)(last.x - first.x), cx = (float)(c.x - first.x), cy = (float)(c.y - first.y);
//cx += c.z; cy += c.z;
float depth_offset = shader.depth_tile_size*(cy*TILE_MAX_DIM*len_x*TILE_MAX_DIM + cx*TILE_MAX_DIM);
- depth_offset += tile_shader::depth_value(local_coords{1*c.z, 1*c.z});
+ const int z = c.z - chunk_min_z;
+ depth_offset += tile_shader::depth_value(local_coords{z, z}, tile_shader::scenery_depth_offset*(z+1));
_shader.set_camera_offset(offset, depth_offset);
}
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index 8ec10610..28bdc759 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -40,7 +40,7 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple
const local_coords pos{i};
const auto quad = atlas->floor_quad(Vector3(pos) * TILE_SIZE, TILE_SIZE2);
const auto texcoords = atlas->texcoords_for_id(_ground_variants[i]);
- const float depth = tile_shader::depth_value(pos);
+ const float depth = tile_shader::depth_value(local_coords{0});
auto& v = vertexes[k];
for (auto j = 0uz; j < 4; j++)
v[j] = { quad[j], texcoords[j], depth };