Re-sort retained transparent phase items when their entity moves - #25708
Open
karasikq wants to merge 6 commits into
Open
Re-sort retained transparent phase items when their entity moves#25708karasikq wants to merge 6 commits into
karasikq wants to merge 6 commits into
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
karasikq
force-pushed
the
fix/refresh-retained-sort-keys
branch
from
September 7, 2026 08:30
84e5a23 to
8054386
Compare
**Objective** - Sorted phases Transparent2d, Transparent3d, Transmissive3d "freeze" their sort key when an component is queued, and moving an entity does not re-queue it, so blended meshes and sprites could draw in the wrong order. **Solution** - Add a `DirtySortKeys` render-world resource, filled in `ExtractSchedule` from entities with a changed `GlobalTransform` and cleared in `RenderSystems::Cleanup`. **Tests** - New `sprite_z_order` example. - New moving-entity scenes in the 2d and 3d testbeds.
karasikq
force-pushed
the
fix/refresh-retained-sort-keys
branch
from
September 7, 2026 08:32
8054386 to
035dcf3
Compare
Member
|
@Tehforsch can I get your review here? Even just testing is extremely helpful. |
| @@ -0,0 +1,81 @@ | |||
| //! Shows that a blended sprite that only moves keeps the right draw order. | |||
Member
There was a problem hiding this comment.
This is not a very useful example pedagogically. Can this be converted into a testbed scene?
Author
There was a problem hiding this comment.
I agree with you. I added it for 2 reasons:
- I saw similar "example" test usage at
bevy/examples/2d/mesh2d_alpha_mode.rs
Lines 1 to 2 in cdf8b09
- I wasn't sure if the "Update" system in the testbed is safe to add, since CI screenshots after 100 frames and the system settles down after a 5. I think it's reasonable to keep
sprite_z_orderwithtransparent_sort_positionand drop the example.
I just checked, this fixes the bug for me, both in the minimal example in #24826 and in my game. |
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.
Objective
and moving an entity does not re-queue it, so blended meshes and sprites could draw in the wrong order.
Solution
DirtySortKeysrender-world resource, filled inExtractSchedulefrom entities with a changedGlobalTransformand cleared inRenderSystems::Cleanup.Testing
sprite_z_orderexample.NOTE: added tests test only position invalidation, if
DirtySortKeyshas another invalidation key then tests must be extended too. Also I introduced anUpdatesystem in the testbed, which is a precedent and I'm not sure the testbed is the right place for such a case.