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

Can't load textures in gray color space #91600

Open
passivestar opened this issue May 5, 2024 · 9 comments
Open

Can't load textures in gray color space #91600

passivestar opened this issue May 5, 2024 · 9 comments

Comments

@passivestar
Copy link
Contributor

passivestar commented May 5, 2024

Tested versions

v4.3.dev6.official [89850d5]

System information

Godot v4.3.dev6 - macOS 14.4.1 - Vulkan (Forward+) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

Issue description

image

This is what macos tells me about them:

image

This is what some online analyzer tells:

image image

image

RGB textures load with no problem

Steps to reproduce

MRP

Minimal reproduction project (MRP)

Image that gives an identical error provided by @theraot:

https://github.com/user-attachments/files/15511511/new_test.zip

@theraot
Copy link
Contributor

theraot commented May 31, 2024

I did some testing, playing with export settings in Gimp and seeing what caused an error. And what caused an error - which looks identical to the OP one - was trying to import a jpg exported with the setting "Use arithmetic coding". I cannot guarantee that it is the same issue, but this is the only way I managed to get the error, so I believe it likely is.

Gimp documentation says:

Arithmetic encoding is a form of entropy encoding (a lossless data compression scheme) that, since GIMP-2.10 can be used in exporting as JPEG. Images using arithmetic encoding can be 5 - 10 % smaller. But older software may have trouble opening these images.

Here is a wikipedia article on the topic: https://en.wikipedia.org/wiki/Arithmetic_coding

Here is the picture I created: test.zip

Notes:

  • Since that has nothing to do with grayscale, I added color to my test picture, which didn't change the error. The picture is a blurry red handrown question mark with black shadow.
  • I only tested jpg.
  • Windows 10 paint and photo apps can't open the picture either. Irfanview and Gimp can.

Now, this is not a regression. I tested the same picture on multiple versions of Godot, and all versions from Godot 3.2 to 3.6 beta4 and from Godot 4.0 alpha1 to Godot 4.3 dev6 had a similar error (with differences in line number).

I hope this allows you to workaround the issue, and perhaps confirm if your textures use arithmetic coding.

And about fixes... Barring adding support for these pictures, this limitation should be documented, and perhaps the error message could be changed to something more useful.

@Calinou
Copy link
Member

Calinou commented May 31, 2024

was trying to import a jpg exported with the setting "Use arithmetic coding"

This option is known for being poorly supported in various programs (even some web browsers will fail to load those JPEGs).

To improve the error message, I'm not sure if there's a reliable way to detect whether a JPEG uses arithmetic coding (either using the jpeg library we're currently using, or by reading the file's bytes directly if it faisl to load).

@theraot
Copy link
Contributor

theraot commented May 31, 2024

It seems to be already detected, although I do not know if that is surfaced to Godot: https://github.com/godotengine/godot/blob/master/thirdparty/jpeg-compressor/jpgd.cpp#L1054

@passivestar
Copy link
Contributor Author

This option is known for being poorly supported in various programs (even some web browsers will fail to load those JPEGs)

Tested my problematic images with different software, all of the following load them with no problem:

  • Blender
  • Unity
  • Affinity Photo
  • Davinci Resolve
  • Substance Painter
  • Brave browser
  • Firefox browser
  • macOS built-in notes app
  • Libre Office Writer

I couldn't find any app that wouldn't open them. So maybe it's a different problem?

@theraot
Copy link
Contributor

theraot commented May 31, 2024

Ok, on my end Firefox won't render my test picture, so you might be correct on this being a different issue.

Notes:

  • Libre Office Writer and Blender have no problem with my test picture. I didn't test any of the other mentioned applications.
  • I'm testing on Windows 10.

@passivestar
Copy link
Contributor Author

I put an image through some online analyzer and attached the results on top in case that gives any ideas

@theraot
Copy link
Contributor

theraot commented May 31, 2024

That confirms it does not have the markers for arithmetic encoding, but for Huffman encoding.

I'll post if I manage to make a test picture that resembles the OP info and causes the import error.

@theraot
Copy link
Contributor

theraot commented May 31, 2024

Ok, I have another problematic picture:
new_test.zip (this time it is an exclamation mark because why not).

This is a Grayscale image with Chromma subsampling 4:2:0 (Gimp didn't let me set this subsampling, forcing 4:4:4 when using Grayscale, so I had to resource to other tools).

None of the applications that had problems with the old test picture have problems with this one. But the error message on Godot is the same. And I didn't find a version of Godot that would import it either.

@passivestar
Copy link
Contributor Author

None of the applications that had problems with the old test picture have problems with this one. But the error message on Godot is the same. And I didn't find a version of Godot that would import it either.

Can confirm the same behavior on macOS

Here's your test picture loaded in unity with no problem:

image

Attached your picture as an MRP

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

No branches or pull requests

4 participants