summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-25 22:31:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-25 22:31:19 +0200
commit0c4150bcf42795e91a62991321b8dd1375766e18 (patch)
tree2cd99dedf469a9ceb3f007768506ebe19652989f /shaders
parent9eaff72af2b1d80f92f6a4534690c9dce7a5bc2e (diff)
actually chunk offset is necessary
Diffstat (limited to 'shaders')
-rw-r--r--shaders/lightmap.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index c676808e..43f71243 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -45,6 +45,7 @@ constexpr auto half_neighbors = (int)poor_mans_ceil(neighbor_count/2.f);
constexpr auto image_size = TILE_SIZE2 * TILE_MAX_DIM * neighbor_count;
constexpr auto chunk_size = TILE_SIZE2 * TILE_MAX_DIM;
+constexpr auto chunk_offset = TILE_SIZE2/2;
constexpr auto clip_start = Vector2{-1, -1};
constexpr auto clip_scale = 2/image_size;
@@ -240,7 +241,7 @@ void lightmap_shader::add_light(Vector2 neighbor_offset, const light_s& light)
range *= tile_size;
range = std::fmax(0.f, range);
- auto center_fragcoord = light.center + neighbor_offset * chunk_size; // window-relative coordinates
+ auto center_fragcoord = light.center + neighbor_offset * chunk_size + chunk_offset; // window-relative coordinates
auto center_clip = clip_start + center_fragcoord * clip_scale; // clip coordinates
float alpha = light.color.a() / 255.f;
@@ -304,7 +305,7 @@ int lightmap_shader::iter_bounds()
void lightmap_shader::add_rect(Vector2 neighbor_offset, Vector2 min, Vector2 max)
{
- auto off = neighbor_offset*chunk_size;
+ auto off = neighbor_offset*chunk_size + chunk_offset;
min += off;
max += off;