From b25f19d99a78099e10319983cb8230266a2c9870 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 13 Jun 2023 04:30:28 +0200 Subject: shaders: use exact value for foreshortening factor --- shaders/shader.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'shaders/shader.hpp') diff --git a/shaders/shader.hpp b/shaders/shader.hpp index 06bf2928..79ceb940 100644 --- a/shaders/shader.hpp +++ b/shaders/shader.hpp @@ -66,14 +66,16 @@ constexpr Math::Vector2 tile_shader::project(const Math::Vector3& pt) { static_assert(std::is_floating_point_v); const auto x = pt[0], y = pt[1], z = -pt[2]; - return { x-y, (x+y+z*2)*T(.59) }; + return { x-y, (x+y+z*2)*T(foreshortening_factor) }; } template constexpr Math::Vector2 tile_shader::unproject(const Math::Vector2& px) { + static_assert(std::is_floating_point_v); const auto X = px[0], Y = px[1]; - return { X + 100 * Y / 59, 100 * Y / 59 - X }; + const auto Y_ = Y / T(foreshortening_factor); + return { X + Y_, Y_ - X }; } } // namespace floormat -- cgit v1.2.3