diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-13 04:30:28 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-13 05:06:49 +0200 |
commit | b25f19d99a78099e10319983cb8230266a2c9870 (patch) | |
tree | 2d9e7519222f73b591731edf67b967892d38e9a6 /shaders/shader.hpp | |
parent | e3b48d03689a07bc19805e4db748f18fc263392b (diff) |
shaders: use exact value for foreshortening factor
Diffstat (limited to 'shaders/shader.hpp')
-rw-r--r-- | shaders/shader.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<T> tile_shader::project(const Math::Vector3<T>& pt) { static_assert(std::is_floating_point_v<T>); 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<typename T> constexpr Math::Vector2<T> tile_shader::unproject(const Math::Vector2<T>& px) { + static_assert(std::is_floating_point_v<T>); 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 |