diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-02 08:07:10 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-02 20:25:31 +0100 |
commit | 0fe5336b9a53f20817f54be0bd7cd935db14914c (patch) | |
tree | 8edc10427d2afe9936abf61b6ce00fc27e828999 | |
parent | bfd3d9c801afd7c2262c9dace18c37d1681d7812 (diff) |
fix texel offset
-rw-r--r-- | src/tile-atlas.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp index 624b4694..11c3e6ae 100644 --- a/src/tile-atlas.cpp +++ b/src/tile-atlas.cpp @@ -37,12 +37,12 @@ auto tile_atlas::make_texcoords(Vector2ui pixel_size, Vector2ub tile_count, std: const auto sz = pixel_size/Vector2ui{tile_count}; const Vector2ui id = { std::uint32_t(i % tile_count[0]), std::uint32_t(i / tile_count[0]) }; const Vector2 p0(id * sz), p1(sz); - const auto x0 = p0.x(), x1 = p1.x()-1, y0 = p0.y(), y1 = p1.y()-1; + const auto x0 = p0.x()+.5f, x1 = p1.x()-1, y0 = p0.y()+.5f, y1 = p1.y()-1; return {{ { (x0+x1) / pixel_size[0], (y0+y1) / pixel_size[1] }, // bottom right { (x0+x1) / pixel_size[0], y0 / pixel_size[1] }, // top right { x0 / pixel_size[0], (y0+y1) / pixel_size[1] }, // bottom left - { x0 / pixel_size[0], y0 / pixel_size[1] } // top left + { x0 / pixel_size[0], y0 / pixel_size[1] }, // top left }}; } |