summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-14 12:53:00 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-14 12:53:00 +0200
commit879c76e8fc1c6aa4e23fe0b5ed7ac62e6b1caeb4 (patch)
treeca2d5ba5e99c878144941be1bb3b04507058d0df
parentf5c387da470ae43a2c8aff75b419e784c8bb3bc5 (diff)
renders almost correctly
Can't be done any better without using topo sort (which means full vbo uploads each frame).
-rw-r--r--main/draw.cpp4
-rw-r--r--shaders/tile.cpp9
-rw-r--r--shaders/tile.hpp6
-rw-r--r--src/character.cpp2
4 files changed, 12 insertions, 9 deletions
diff --git a/main/draw.cpp b/main/draw.cpp
index 0e4ecc9f..a8bac01c 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -103,8 +103,8 @@ auto main_impl::get_draw_bounds() const noexcept -> draw_bounds
y1 = std::max(y1, p.y);
}
- constexpr int16_t maxx = tile_shader::max_screen_tiles.x()/2 - 1, minx = -maxx,
- maxy = tile_shader::max_screen_tiles.y()/2 - 1, miny = -maxy;
+ const int16_t maxx = tile_shader::max_screen_tiles.x()/2 - 1, minx = -maxx,
+ maxy = tile_shader::max_screen_tiles.y()/2 - 1, miny = -maxy;
x0 = std::clamp(x0, minx, maxx);
x1 = std::clamp(x1, minx, maxx);
diff --git a/shaders/tile.cpp b/shaders/tile.cpp
index 9c347021..c8defb43 100644
--- a/shaders/tile.cpp
+++ b/shaders/tile.cpp
@@ -78,8 +78,11 @@ float tile_shader::depth_value(const local_coords& xy, float offset) noexcept
return ((float)xy.x + (float)xy.y + offset) * depth_tile_size;
}
-const float tile_shader::scenery_depth_offset = 1./64;
-const float tile_shader::wall_depth_offset = 0;
-const float tile_shader::z_depth_offset = 1e-4f;
+const Vector2s tile_shader::max_screen_tiles = {8, 8};
+const float tile_shader::character_depth_offset = 1 + 4./64;
+const float tile_shader::scenery_depth_offset = 1 + 4./64;
+const float tile_shader::wall_depth_offset = 1;
+const float tile_shader::z_depth_offset = 1./64;
+const float tile_shader::depth_tile_size = 1/(double)(TILE_MAX_DIM * 2 * max_screen_tiles.product());
} // namespace floormat
diff --git a/shaders/tile.hpp b/shaders/tile.hpp
index 19d2d552..280850b9 100644
--- a/shaders/tile.hpp
+++ b/shaders/tile.hpp
@@ -37,9 +37,9 @@ struct tile_shader : GL::AbstractShaderProgram
template<typename T, typename... Xs>
decltype(auto) draw(T&& mesh, Xs&&... xs);
- static constexpr Vector2s max_screen_tiles{8, 8};
- static constexpr float depth_tile_size = 1/(double)(TILE_MAX_DIM * 2 * max_screen_tiles.product());
- static const float scenery_depth_offset, wall_depth_offset, z_depth_offset;
+ static const Vector2s max_screen_tiles;
+ static const float depth_tile_size;
+ static const float character_depth_offset, scenery_depth_offset, wall_depth_offset, z_depth_offset;
private:
void _draw();
diff --git a/src/character.cpp b/src/character.cpp
index b00ba73a..a2d85cb3 100644
--- a/src/character.cpp
+++ b/src/character.cpp
@@ -132,7 +132,7 @@ void character::set_keys(bool L, bool R, bool U, bool D)
float character::depth_offset() const
{
- return tile_shader::scenery_depth_offset;
+ return tile_shader::character_depth_offset;
}
Vector2 character::ordinal_offset(Vector2b offset) const