Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4beta1] Adding CanvasTexture to a Sprite2D remains white until complete restart of editor #101702

Closed
woutercommandeur opened this issue Jan 17, 2025 · 14 comments · Fixed by #101931

Comments

@woutercommandeur
Copy link

Tested versions

Reproduced in 4.4beta and 4.4dev7, did not test other versions.

System information

Godot v4.4.beta1 - Windows 11 (build 26100) - Multi-window, 3 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 32.0.15.6590) - Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz (20 threads)

Issue description

In order to create a new CanvasTexture I add a Sprite2D to my scene. Then I click CanvasTexture at the top right and a small white square where the sprite is supposed to be appears in my 2D scene. I then drag a Diffuse and Normal texture into the correct boxes and the square resizes to the size of my textures but remains white. I expected it to show my texture. I then restart Godot completely and it will show the texture when I open the project. I tried reloading the project after creating the sprite but that does not work.

Steps to reproduce

  1. Add new Sprite2D
  2. Click the Texture and select CanvasTexture
  3. Observe the white sprite in your 2D view
  4. Drag in Diffuse and Normal texture
  5. Still observe white sprite
  6. Try reloading the project
  7. Still observe the white sprite
  8. Restart godot completely
  9. Observe your texture

Minimal reproduction project (MRP)

I did not add a minimal reproduction project as loading that will actually work.

@clayjohn
Copy link
Member

I followed the reproduction steps with 4.4 beta 1 and was unable to reproduce the issue. As soon as I dropped the texture on the "diffuse" slot, the texture appeared correctly

@woutercommandeur
Copy link
Author

woutercommandeur commented Jan 17, 2025

I added 4 pictures to illustrate, fresh empty project. Last picture is after reloading godot.

Image
Image
Image
Image

@JekSun97
Copy link
Contributor

JekSun97 commented Jan 17, 2025

I didn't really understand what the problem was, but if the point is that after rebooting, instead of CanvasTexture, you have your sprite texture, then yes, after rebooting, I also see the texture instead of CanvasTexture

Image

Godot v4.4.beta1 - Windows 10 (build 19045) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Radeon RX 560 Series (Advanced Micro Devices, Inc.; 31.0.14001.45012) - Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 threads)

@woutercommandeur
Copy link
Author

In previous versions adding a diffuse to the canvastexture would show the correct texture immediately instead of a white texture. Restarting godot to show the correct texture is not a good workflow.

@Giganzo
Copy link
Contributor

Giganzo commented Jan 17, 2025

In 4.4.dev6 the image is displayed directly when dropped in diffuse. But not in 4.4beta1, I can reload the scene and it shows

@clayjohn
Copy link
Member

clayjohn commented Jan 17, 2025

@woutercommandeur To be clear, no one is saying that a restart should be required. JekSun and I just can't reproduce the issue. When we drop the texture into the diffuse slot it displays the texture immediately.

I tested on a linux system. Perhaps this is an issue with drag and drop on Windows only. I can try there as well

@Giganzo
Copy link
Contributor

Giganzo commented Jan 17, 2025

I tested on a linux system. Perhaps this is an issue with drag and drop on Windows only. I can try there as well

I tested on Fedora Linux 41 (KDE Plasma) on Wayland - Wayland display driver, Single-window

Edit added video

beta1

Screencast_20250117_200143.webm

dev6

Screencast_20250117_200308.webm

@JekSun97
Copy link
Contributor

Now that I have figured out the root of the problem, I can confirm that this is indeed happening, I want to point out that this problem does not exist in Compatibility mode, but it did occur in Forward+.

Godot v4.4.beta1 - Windows 10 (build 19045) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated Radeon RX 560 Series (Advanced Micro Devices, Inc.; 31.0.14001.45012) - Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 threads)

@woutercommandeur
Copy link
Author

Thanks all! I had trouble getting my problem across but you guys jumped on it!

@EmilyV99
Copy link

Possibly related, it appears that scripts changing the .diffuse_texture of a CanvasTexture does not cause it to redraw? For my game I'm working on, this results in my character suddenly no longer turning to face left ever...

@woutercommandeur
Copy link
Author

Possibly related, it appears that scripts changing the .diffuse_texture of a CanvasTexture does not cause it to redraw? For my game I'm working on, this results in my character suddenly no longer turning to face left ever...

Updating the diffuse texture after reloading the editor also does not update either. So I think this is indeed the same issue.

@clayjohn
Copy link
Member

CC @stuartcarnie This sounds like a regression in how we cache the batch textures.

@stuartcarnie
Copy link
Contributor

@clayjohn going to add an invalidation callback to TextureStorage so that when clear_cache is called, we can invalidate the uniform set.

@stuartcarnie
Copy link
Contributor

#101931 will fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

6 participants