summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-06-13 04:30:28 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-06-13 05:06:49 +0200
commitb25f19d99a78099e10319983cb8230266a2c9870 (patch)
tree2d9e7519222f73b591731edf67b967892d38e9a6 /shaders
parente3b48d03689a07bc19805e4db748f18fc263392b (diff)
shaders: use exact value for foreshortening factor
Diffstat (limited to 'shaders')
-rw-r--r--shaders/shader.hpp6
-rw-r--r--shaders/shader.vert2
2 files changed, 5 insertions, 3 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
diff --git a/shaders/shader.vert b/shaders/shader.vert
index a539ed6b..9190fe8d 100644
--- a/shaders/shader.vert
+++ b/shaders/shader.vert
@@ -10,6 +10,6 @@ noperspective out vec2 frag_texcoords;
void main() {
float x = -position.y, y = -position.x, z = position.z;
- gl_Position = vec4((x-y+offset.x)*scale.x, ((x+y+z*2)*.59-offset.y)*scale.y, offset.z + depth, 1);
+ gl_Position = vec4((x-y+offset.x)*scale.x, ((x+y+z*2)*0.578125-offset.y)*scale.y, offset.z + depth, 1);
frag_texcoords = texcoords;
}