godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.83k stars 21.13k forks source link

ParallaxLayer does not respect z-index when motion_mirroring is set #75115

Open qaptoR opened 1 year ago

qaptoR commented 1 year ago

Godot version

4.0 Stable and 4.0.1-rc2

System information

Windows 10, Forward+, Nvidia 3090 v 531.29

Issue description

When using motion_mirroring for a ParallaxLayer, the only draw ordering which the Texture2D respects is the tree order of Parralax Layers and CanvasLayers

Steps to reproduce

There are two scenes without_mirroring_A_over_B and with_mirroring_A_over_B. They are named as such because their z-index values should order them such that A is drawn over B.

You can reorder the tree-order of the two ParallaxLayers that contain SpriteA and SpriteB. You will see that for without_mirroring... it has no affect on draw order, but it does have an affect on with_mirroring....

Additionally, you can reorder SpriteD which shows the same thing, that ParallaxLayer does not consider z-index whatsoever when motion_mirroring is used.

Minimal reproduction project

ParallaxLayerOrdering.zip

JorgeO3 commented 9 months ago

This bug is also present in godot 3.5.3.stable.mono.

belzecue commented 3 months ago

Confirmed bug in 3.6RC1

Parallax layer with NO mirroring. Screen-2024-07-21_15-24-12

Parallax layer with X mirroring applied (no other changes). Screen-2024-07-21_15-24-40

The Godot sprite has a z-index of 1000 and therefore should be drawn above the parallax layers. Screen-2024-07-21_15-24-54

Moving the Godot sprite to bottom of tree puts it back on top. Screen-2024-07-21_15-32-31

Workaround is to simply manually duplicate and contiguously place the background sprite under the parallax layer instead of relying on motion_mirror, and leave motion_mirror at zero for all layers. Node z-order is then respected.

Screen-2024-07-21_16-05-02

markdibarry commented 2 months ago

Working for both ParallaxLayer and Parallax2D in 4.3. We draw the repeats differently now, so it respects z-index and scene order.