Skip to content

Add flipped GPU tiles example - #411

Open
moufmouf wants to merge 1 commit into
phaserjs:masterfrom
moufmouf:example/tilemapgpulayer-flipped-tiles
Open

Add flipped GPU tiles example#411
moufmouf wants to merge 1 commit into
phaserjs:masterfrom
moufmouf:example/tilemapgpulayer-flipped-tiles

Conversation

@moufmouf

@moufmouf moufmouf commented Aug 31, 2026

Copy link
Copy Markdown

Companion example for the TilemapGPULayer frame-edge sampling fix in phaserjs/phaser#7360 (linked from that PR).

Before (the bleeding can appear only briefly when loading the page):

image

(see the colored lines?)

After the fix in phaserjs/phaser#7360 :

image

TilemapGPULayer resolves 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, 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. On stock 4.2.x, orange lines appear along the tile edges in the flipY quadrants and green ones in the flipX quadrants, 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 ParseGID folds those three bits into rotation plus a single flipped flag, and ParseTileLayers assigns only tile.rotation and tile.flipX — so a map file can never produce a tile.flipY.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant