diff options
-rw-r--r-- | src/camera-offset.cpp | 5 | ||||
-rw-r--r-- | src/global-coords.cpp | 2 | ||||
-rw-r--r-- | src/global-coords.hpp | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp index 959fe4d5..fb4724cc 100644 --- a/src/camera-offset.cpp +++ b/src/camera-offset.cpp @@ -17,7 +17,10 @@ with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, chun //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); 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)); + depth_offset += tile_shader::depth_value(local_coords{z, z}); + + if (c.z == chunk_max_z) + depth_offset = 1; _shader.set_camera_offset(offset, depth_offset); } diff --git a/src/global-coords.cpp b/src/global-coords.cpp index 87a2c79c..de7c9ee2 100644 --- a/src/global-coords.cpp +++ b/src/global-coords.cpp @@ -13,7 +13,7 @@ static_assert(TILE_MAX_DIM == (1 << 4)); static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM-1, 0}.chunk() == global_coords{}.chunk()); static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM, 0}.chunk() == chunk_coords{0, 1}); -static_assert(global_coords{(1u + (1<<15)) << 4 | 3, (2u + (1<<15)) << 4 | 4, nullptr} == global_coords{{1, 2}, {3, 4}, -8}); +static_assert(global_coords{(1u + (1<<15)) << 4 | 3, (2u + (1<<15)) << 4 | 4, nullptr} == global_coords{{1, 2}, {3, 4}, -1}); static_assert(global_coords{-123, 456, 1}.z() == 1); static_assert(global_coords{-123, 511, 5}.chunk() == chunk_coords{-8, 31}); diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 1bf79e4a..c86cee59 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -37,12 +37,12 @@ struct chunk_coords_ final { constexpr bool operator==(const chunk_coords_&) const noexcept = default; }; -constexpr inline int8_t chunk_min_z = -8, chunk_max_z = 7; +constexpr inline int8_t chunk_min_z = -1, chunk_max_z = 14; struct global_coords final { using u0 = std::integral_constant<uint32_t, (1<<15)>; using s0 = std::integral_constant<int32_t, int32_t(u0::value)>; - using z0 = std::integral_constant<int32_t, (1 << 3)>; + using z0 = std::integral_constant<int32_t, (1 << 0)>; using z_mask = std::integral_constant<uint32_t, (1u << 4) - 1u << 20>; uint32_t x = u0::value<<4|z0::value<<20, y = u0::value<<4; |