From 506f87c554153eb0bbc3bc9e4fb0f26792f8bfca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 12 Apr 2023 15:53:09 +0200 Subject: depth buffer fixes --- shaders/tile.cpp | 3 ++- shaders/tile.hpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'shaders') diff --git a/shaders/tile.cpp b/shaders/tile.cpp index d5f6b7d3..d774ddf0 100644 --- a/shaders/tile.cpp +++ b/shaders/tile.cpp @@ -2,6 +2,7 @@ #include "loader/loader.hpp" #include "compat/assert.hpp" #include "local-coords.hpp" +#include #include #include #include @@ -74,7 +75,7 @@ void tile_shader::_draw() float tile_shader::depth_value(const local_coords& xy, float offset) noexcept { - return depth_tile_size + (xy.to_index() + offset)*depth_tile_size; + return (float)((xy.to_index() + (double)offset) * depth_tile_size); } } // namespace floormat diff --git a/shaders/tile.hpp b/shaders/tile.hpp index fd3788f3..8415d836 100644 --- a/shaders/tile.hpp +++ b/shaders/tile.hpp @@ -37,9 +37,9 @@ struct tile_shader : GL::AbstractShaderProgram template decltype(auto) draw(T&& mesh, Xs&&... xs); - static constexpr float depth_tile_size = 3.56e-15; // 1 - nextafter(1, 0) * TILE_MAX_DIM / 2 - static constexpr float depth_start = -1 + depth_tile_size; - static constexpr float scenery_depth_offset = .5f, character_depth_offset = .5f; + static constexpr double depth_tile_size = 1/(double)(TILE_COUNT * 16 * 16); + static constexpr double depth_chunk_size = 1/(double)(16 * 16); + static constexpr float scenery_depth_offset = 0.5f, character_depth_offset = 0.5f, wall_depth_offset = 0.25f; private: void _draw(); -- cgit v1.2.3