Skip to content

feat: Add culling support for Tiled layers with tiles bigger than their cells - #4126

Open
ufrshubham wants to merge 3 commits into
mainfrom
devkage/tiled-run-culling
Open

ufrshubham wants to merge 3 commits into
mainfrom
devkage/tiled-run-culling

Conversation

@ufrshubham

@ufrshubham ufrshubham commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Description

#4124 skips the tiles of a Tiled layer that are out of view by splitting the layer in square chunks.
That only works when every tile stays inside of its cell. Tiles that are bigger than their cells,
like the cubes and trees of many isometric tilesets, tiles with an offset, and tiles turned a
quarter in cells that are not square, are painted over the tiles around them. Drawing them chunk
by chunk could change which tile ends up on top, so #4124 keeps those layers in a single batch,
which is drawn in full on every frame.

This PR splits those layers in runs instead: pieces of one row of tiles, of up to four times
chunkSize tiles, which are drawn in the same order as the tiles are painted in. The layer looks
exactly like a layer that is not split, and the runs that are out of view are skipped.

  • Nothing changes in the API. chunkSize is still the only option, and maps that don't set it
    (and are not infinite) are not split, as before.
  • Layers whose tiles fit their cells keep using the square chunks of feat: Add culling support for out of view tiles in TiledComponent #4124, which need fewer draw
    calls. Flame picks runs or chunks for each layer when it is loaded.
  • tileStack keeps the run of a tile that is handed out drawn, like it does for chunks.

Tests and examples

  • New tests load the 26 maps of test/assets that have tiles bigger than their cells, flips,
    offsets or tall hexagons. They check that the layers are split in runs, and that they render
    pixel for pixel what they render without splitting, with and without a camera. With chunks
    instead of runs, 13 of these comparisons fail.
  • The tests that checked that these layers are not split now check that they use runs.
  • The culling examples have a new "Isometric, tall tiles (runs)" option in the "Orientation" knob,
    with a map of trees and rocks that are taller than their cells. The visualized example draws the
    runs instead of the chunks for it.
  • tile_layer_benchmark.dart has cases with tiles that have an offset, which are split in runs.

Demo (Windows)

tiled_culling_isometric_tall_windows.mp4
tiled_culling_visualized_isometric_tall_windows.mp4

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

@ufrshubham
ufrshubham added this pull request to stack #4127 October 21, 2026 16:46
Base automatically changed from devkage/tiled-chunk-culling to main October 23, 2026 18:29
…that stick out of their cells

Layers with tiles that are bigger than their cells, or that have an offset, were
not split, because drawing their tiles chunk by chunk could change which tile is
painted on top. These layers are now split in runs: pieces of one row, drawn in
the order that the tiles are painted in, so they look exactly like a layer that
is not split.
@ufrshubham
ufrshubham force-pushed the devkage/tiled-run-culling branch from b26cf75 to 7d1176c Compare October 23, 2026 18:31
@ufrshubham
ufrshubham marked this pull request as ready for review October 23, 2026 18:32

This branch has not been deployed

No deployments
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