Open Calinou opened 2 years ago
WebP only supports a limited set of formats. The only ones that are of interest to us are RGB and RGBA. (The others are YUV and other exotic things.)
I see 2 options:
StreamTexture::_load_data()
function, or passed into the specific loaders (which might be able to do the conversion more efficiently)If we want to go the route with storing a hint, we should also look into checking which channels are used during import, to make sure a grayscale texture always gets loaded as grayscale, even if the PNG file is RGB.
If we want to go the route with storing a hint, we should also look into checking which channels are used during import, to make sure a grayscale texture always gets loaded as grayscale, even if the PNG file is RGB.
I think this would be the ideal solution, as not everyone saves their grayscale images with a grayscale format. It would slow down importing a little as every pixel's color needs to be checked, but I think it's worth it.
Godot version
4.0.dev (1032c2c43),
3.x
(08ce24a3c), 3.4.2.stableSystem information
Fedora 34, GeForce GTX 1080 (NVIDIA 495.46)
Issue description
Unlike PNG compression, lossless WebP compression (enabled by default since Godot 3.4) will not use the L8/LA8 formats (referred to as Lum8 and LumAlpha8 in the inspector preview). Instead, RGB8 or RGBA8 will always be used, which wastes memory.
This can be worked around by enabling Force Png in the Project Settings then reimporting all textures that are imported with lossless compression.
See my complete investigation here: https://github.com/godotengine/godot-proposals/issues/2107#issuecomment-1005752219
cc @mortarroad
Steps to reproduce
Minimal reproduction project
master
: test_image_formats.zip3.x
: test_image_formats_3.x.zip