-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Texture broken with mipmaps enabled #50647
Comments
Confirmed on Jetpaca with this texture: https://github.com/KOBUGE-Games/jetpaca/blob/master/art/intro_sky_bg.png It's a regression specific to |
Bisected to #47854, CC @mortarroad. |
Hmm, doesn't seem to be caused by my commit, just revealed by it. However, the Texture resource loaded assumes all of its images to have the same format. It just uses the format of the first mipmap image, and copies them consecutively in memory. godot/scene/resources/texture.cpp Lines 582 to 599 in ab30437
Different formats can happen, if the source image has very few transparent pixels, such that a smaller mip map ends up with no transparency. A quick fix is to let WebP always decode to RGBA. |
Adding this
right here godot/scene/resources/texture.cpp Line 567 in ab30437 total_size ) fixes it.
Also, while I'm here, let me reiterate how silly it is to store mipmaps on disk other than for VRAM compression formats. |
Looking into 4.x, that seems to have equivalent code. godot/scene/resources/texture.cpp Lines 369 to 376 in 7f0a83c
My fix is shorter though, hehe. |
Converting on load is inefficient, IMO the webp decoder should be told the desired format instead with a hint. |
I disagree. I estimate that a conversion happens in less than 1% of the cases and then only for the lowest mipmap levels, which are small anyway (a few pixels at worst). Either way, the proper fix here is to add the conversion, as in 4.x. Looking through the code, this issue affects at least one more encoder, possibly others too: godot/drivers/png/png_driver_common.cpp Lines 155 to 162 in 0543b71
|
Yeah upon closer inspection you are right, this should happen so little often its not worth having a more complex workaround. |
Fixed by #51555. |
Godot version
3.4 beta1
System information
W10
Issue description
I have a texture that can't be imported with mipmaps enabled. It shows this error:
And image format shows Lum8. The texture becomes black rectangle.
This doesn't happen with other textures, even smaller ones.
Apparently it was fine some time ago and only broke recently. Also works in 4.0.
Steps to reproduce
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: