diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 16:17:23 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 16:17:23 +0100 |
commit | 1febb02d958fa4cf8c15e3ca18f9d644f9fc80fb (patch) | |
tree | d9b389f6c2ff8e031bd70d503c289bcfddf2f048 /shaders/tile.cpp | |
parent | 09605450ecc99ad1f4d50e9c143fda6c7762e702 (diff) |
depth buffer works!
Diffstat (limited to 'shaders/tile.cpp')
-rw-r--r-- | shaders/tile.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/shaders/tile.cpp b/shaders/tile.cpp index 2fb37cd8..c8261acd 100644 --- a/shaders/tile.cpp +++ b/shaders/tile.cpp @@ -1,6 +1,7 @@ #include "shaders/tile.hpp" #include "loader.hpp" #include "compat/assert.hpp" +#include "local-coords.hpp" #include <Magnum/Math/Vector4.h> #include <Magnum/GL/Context.h> #include <Magnum/GL/Shader.h> @@ -65,4 +66,13 @@ void tile_shader::_draw() } } +float tile_shader::depth_value(const local_coords& xy) noexcept +{ + constexpr float max = (TILE_MAX_DIM+1)*(TILE_MAX_DIM+1) * .5f; + constexpr float min = -1 + 1.f/256; + float value = min + xy.to_index()/max; + fm_assert(value > -1 && value < 1); + return value; +} + } // namespace floormat |