Add flipped GPU tiles example - #411
Open
moufmouf wants to merge 1 commit into
Open
Conversation
TilemapGPULayer resolves tiles from the tileset in a fragment shader, so a flipped tile has to keep sampling inside its own frame even when a fragment lands exactly on a tile boundary. Fills a layer with one asymmetric tile flipped four ways - unflipped, flipX, flipY and both, one per quadrant - and surrounds that tile in the tileset with colours the map never uses: orange directly above it, green directly to its right. The camera creeps through sub-pixel offsets, which is when tile boundaries line up with fragment centres. Nothing on screen should ever be orange or green. The flips are set on the tiles rather than encoded in the map data on purpose: Tiled packs flips into the high bits of a GID, but ParseGID folds those three bits into `rotation` plus a single `flipped` flag, so a map file can only ever produce `tile.flipX`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
moufmouf
force-pushed
the
example/tilemapgpulayer-flipped-tiles
branch
from
August 31, 2026 10:23
bf4b23b to
f7a5c91
Compare
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.
Companion example for the
TilemapGPULayerframe-edge sampling fix in phaserjs/phaser#7360 (linked from that PR).Before (the bleeding can appear only briefly when loading the page):
(see the colored lines?)
After the fix in phaserjs/phaser#7360 :
TilemapGPULayerresolves a tile's pixels from the tileset in a fragment shader, so a flipped tile has to keep sampling inside its own frame even when a fragment lands exactly on a tile boundary.This example fills a layer with one asymmetric tile flipped four ways — unflipped,
flipX,flipYand both, one per quadrant — and surrounds that tile in the tileset with colours the map never uses: orange directly above it, green directly to its right. The camera creeps through sub-pixel offsets, which is when tile boundaries line up with fragment centres.Nothing on screen should ever be orange or green. On stock 4.2.x, orange lines appear along the tile edges in the
flipYquadrants and green ones in theflipXquadrants, flickering in and out as the camera moves. Swept over 512 sub-pixel offsets here: 6 orange rows and 8 green columns before the fix, none after.One note on the example: the flips are set on the tiles rather than encoded in the map data on purpose. Tiled packs flips into the high bits of a GID, but
ParseGIDfolds those three bits intorotationplus a singleflippedflag, andParseTileLayersassigns onlytile.rotationandtile.flipX— so a map file can never produce atile.flipY.