Skip to content

[Feature request] Add support for Y-based Z sorting in batch rendering #1526

Description

@Vareniel

Is your feature request related to a problem? Please describe.

Yes. I need a Y-based Z sorting feature for sprites, especially when using batch rendering.

Currently, I use custom auto-sorting logic that updates each object’s pos.z based on pos.y and _anchorZ property. This works for normal rendering, but batch rendering can cause incorrect render order, disappearing sprites, or a sprite using another sprite’s texture.

Describe the solution you'd like

I would like batch rendering to support Y-based Z sorting properly.

Objects should be sorted using their calculated pos.z, for example:

nextZ = baseZ + object.pos.y + scaledAnchorZ;

This allows objects lower on the screen to render in front of objects higher on the screen.

Example:

Object A: pos.y = 100
Object B: pos.y = 150

Expected result: Object B should render above Object A because it has a higher pos.y value.

Describe alternatives you've considered

I currently use a custom auto-sort system that updates pos.z manually and calls container.sort(). However, this does not fully work with batch rendering.

I also tried disabling auto sorting, but that caused other rendering issues, such as sprites disappearing after one mob is destroyed.

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions