Fix wrong animated tiles used in TilemapGPULayer#7337
Open
moufmouf wants to merge 1 commit into
Open
Conversation
createAnimationDataTexture stored the raw animation ordinal in _animationDataIndexMap, but each animation header occupies 2 texels in the animation data texture (duration and frame offset) and the shader reads the header at texel `index`. Only ordinal 0 landed on a valid header; every animated tile after the first read a bogus header and resolved to a wrong tile. Store the texel offset (`ordinal * 2`), matching how the frame offset is already stored. The map value is consumed only by TilemapGPULayer.generateLayerDataTexture (which looks it up directly) and by SubmitterTilemapGPULayer (which only reads `.size`), so doubling is safe. Fixes phaserjs#7331. 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.
This PR (delete as applicable)
Fixes #7331.
createAnimationDataTexturestored the raw animation ordinal in_animationDataIndexMap, but each animation header occupies 2 texels in the animation data texture (duration and frame offset) and the shader reads the header at texelindex. Only ordinal 0 landed on a valid header; every animated tile after the first read a bogus header and resolved to a wrong tile.Store the texel offset (
ordinal * 2), matching how the frame offset is already stored. The map value is consumed only byTilemapGPULayer.generateLayerDataTexture(which looks it up directly) and bySubmitterTilemapGPULayer(which only reads.size), so doubling is safe.You can view a repro in this fork of the example directory: https://github.com/moufmouf/examples/blob/d2a8077ceb86c3159e67599d89f30e5e9a0a310f/public/src/tilemaps/tilemap%20gpu%20layer/gpu%20tile%20layer%20two%20animated%20tiles.js
(Phaser Sandbox seems down as I am opening this PR)
Before the fix:
After the fix: