godotengine / godot

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

AnimatedTexture frames turn white after changing to a scene that references the same pngs #79070

Open zeblwest opened 1 year ago

zeblwest commented 1 year ago

Godot version

4.1.rc3

System information

Godot v4.1.rc3 - Windows 10.0.22621 - Vulkan (Compatibility) - NVIDIA GeForce RTX 2080 Ti (NVIDIA; 31.0.15.3598) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)

Issue description

When I setup a TextureRect with an AnimatedTexture in once scene, when I change scenes, I'm seeing certain frames of the AnimatedTexture turn completely white.

This seems to happen after a scene change where the other scene references some of the PNGs contained in the other scene's AnimatedTexture

Note: The Editor also seems to think that the referenced PNG should be animated (it's as if it's holding onto some reference to that AnimatedTexture even though all you're doing is dragging in one of the component pngs to use it in a different scene)

Steps to reproduce

I created a Minimal Test project with two scenes - all you do to see the issue is to use 'ui_accept' (Space Bar or Enter Key) to switch between the scenes.

  1. Open the 'AnimatedTextureTest' project
  2. Run the game (press F5)
  3. Observe that the AnimatedTexture in Scene01 is animating (face is blinking and eyes are moving)
  4. Press Space Bar (or Enter) to switch scenes
  5. Observe that the image in Scene02 is corrupted (Completely White)
  6. Press Space Bar again to change scenes
  7. Observe that the frames referenced by Scene02 are also corrupted (white) in the AnimatedTexture now AnimatedTextureGodotBug

Minimal reproduction project

AnimTextureTest.zip

alexissantos commented 1 year ago

I'm also seeing this, but under slightly different circumstances when I build it for Linux.

Nobara Linux 37, Godot Engine v4.0.3.stable.official.5222a99f5 - Vulkan API 1.3.246 - Forward+ - Using Vulkan Device #0: Intel - Intel(R) HD Graphics 530 (SKL GT2)

Expected Behavior (Built for Mac)

Screenshot 2023-07-11 at 12 21 40 PM

Issue (Built for Linux)

Screenshot 2023-07-10 at 11 56 48 PM

I don't reference the PNGs in a previous scene, but I do load these on a new scene. Whenever the animation plays, the transparency works until it stops playing.

I currently have the animation's default frame to be the ninth one. If I change it to the fourth frame, I have no issues with transparency. I've attached them here for reference.

frames.zip

I don't see this issue on my Mac in either the preview or the built game.

alexissantos commented 1 year ago

Working around this bug has helped me uncover a few more details, now using Godot v4.1.stable.official [970459615] to build.

For example, the following spritesheet works just fine: working

But a set of frames including the following does not: broken

fresh4 commented 8 months ago

I wanted to confirm my own experience with this if it adds any information. I've only been having this issue when running my game in compatibility mode in Godot 4.2.1 stable. I don't know the specifics of what causes it for me to create a reproduceable example but here's my use case.

I'm using an animated texture rect as the title image in my main menu scene. Clicking play switches scenes, unloading the menu scene and loading the game scene. If I 'exit to menu' it unloads the game scene and loads the menu scene. Only when I load the menu scene do I find that the animated texture rect has corrupted. Inspecting the remote viewer the texture rect still claims that the correct textures are loaded.

A really odd workaround I've found involves simply saving the animated texture rect as a scene and using that in place of the node in my menu tree. It's virtually the same, but swapping between scenes no longer produces the unexpected behavior for me this way.