A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(tilemap): kill inter-tile seams — half-texel UV inset + de-gradiented wang demo art
esengine548614453ddd
diff --git a/examples/tilemap-demo/assets/tilesets/wang-tiles.png b/examples/tilemap-demo/assets/tilesets/wang-tiles.pngindex 4afc8af50..c327d4ab1 100644Binary files a/examples/tilemap-demo/assets/tilesets/wang-tiles.png and b/examples/tilemap-demo/assets/tilesets/wang-tiles.png differdiff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.cppindex 5061e9b0e..d6584a687 100644--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp@@ -105,11 +105,12 @@ void TilemapRenderPlugin::rebuildChunk(worldY = originY - static_cast<f32>(ty) * layer.tile_height - hh;}- // Base tile UV rect (GL v increases upward, so vBottom < vTop).- f32 uMin = static_cast<f32>(tileCol) * uvTileW;- f32 uMax = uMin + uvTileW;- f32 vBottom = 1.0f - static_cast<f32>(tileRow + 1) * uvTileH;- f32 vTop = vBottom + uvTileH;+ // Base tile UV rect (GL v increases upward, so vBottom < vTop),+ // inset half a texel per edge so samples stay inside this tile.+ f32 uMin = static_cast<f32>(tileCol) * uvTileW + resolved[slotIndex].insetU;+ f32 uMax = uMin + uvTileW - 2.0f * resolved[slotIndex].insetU;+ f32 vBottom = 1.0f - static_cast<f32>(tileRow + 1) * uvTileH + resolved[slotIndex].insetV;+ f32 vTop = vBottom + uvTileH - 2.0f * resolved[slotIndex].insetV;// Map a corner's normalized (s,t) in {0,1}^2 to its texture UV, applying// the tile flip flags. Tiled order — diagonal (transpose) first, then H,@@ -214,6 +215,8 @@ void TilemapRenderPlugin::collect(RenderCollectContext& collect_ctx) {resolved[i].glTexId = tex->getId();resolved[i].uvW = layer.tile_width / tw;resolved[i].uvH = layer.tile_height / th;+ resolved[i].insetU = 0.5f / tw;+ resolved[i].insetV = 0.5f / th;anySlotValid = true;}if (!anySlotValid) continue;diff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.hppindex e9f44196f..2cd6297ac 100644--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp@@ -47,6 +47,12 @@ private:u32 glTexId = 0;f32 uvW = 0.0f;f32 uvH = 0.0f;+ // Half a texel in UV space. Tile-corner UVs are inset by this so+ // interpolated samples never cross into the neighboring atlas tile —+ // the classic packed-atlas seam fix, for both linear and nearest+ // (which otherwise rounds across the boundary at fractional zoom).+ f32 insetU = 0.0f;+ f32 insetV = 0.0f;bool valid = false;};