Add a TilemapGPULayer example covering a tileset with margin != spacing#410
Open
moufmouf wants to merge 1 commit into
Open
Add a TilemapGPULayer example covering a tileset with margin != spacing#410moufmouf wants to merge 1 commit into
moufmouf wants to merge 1 commit into
Conversation
Covers a tileset where margin != spacing (margin=1, spacing=2), which no existing TilemapGPULayer example does - desert is 1/1, MedievalRTS 32/32 and super-mario 0/0, so a stride computed from margin instead of spacing renders identically to a correct one. The sheet is built procedurally and is 32 rows tall; tiles are drawn from rows 0, 8, 16, 24 and 31 with both a GPU TilemapGPULayer and a CPU TilemapLayer, so any per-tile stride error accumulates visibly with the row index. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new test:
tilemaps/tilemap gpu layer/gpu tiles with margin and spacing.js.Every current
TilemapGPULayerexample uses a tileset whosemarginequals itsspacing, so any confusion between the two renders identically to a correctimplementation:
copy gpu tiles.jstmw_desert_spacinganimated gpu tiles.jsMedievalRTS/sample.jsoncpu versus gpu.jssuper-mario.jsonTiled does not couple the two, and
margin=1/spacing=2is common in the wild, sothis is a gap in example coverage rather than an exotic edge case.
This example builds a tileset texture procedurally (no new binary asset) with
margin=1,spacing=2and 32 rows. Each tile carries its own index and hue, and thegutters between tiles are black. It renders tiles taken from sheet rows 0, 8, 16, 24
and 31 with a GPU
TilemapGPULayerand a CPUTilemapLayerside by side, so the twocan be compared directly. A per-tile stride error accumulates with the tile index, so
sampling deep rows makes it visible — row 0 looks correct under any stride.
It also demonstrates the fix in phaserjs/phaser#7339: on v4.2.1 the GPU side
renders the wrong tiles from row 8 downwards, and matches the CPU side once that
lands.
Here is a demonstration of the bug in action:

phaserjs/phaser#7339 fixes the issue