kopaka1822 / ImageViewer

HDR, PFM, DDS, KTX, EXR, PNG, JPG, BMP image viewer and manipulator
MIT License
324 stars 37 forks source link

Why astc and etc2 looks different from orginal png? #21

Closed powof2 closed 2 years ago

powof2 commented 2 years ago

Describe the bug ASTC and ETC2 textures look different from orginal png

To Reproduce use PVRTexToolGUI.exe to encode any png into astc (sRGB) (no mipmap) or ect2 (sRGB) (no mipmap), container is ktx. in PVRTexToolGUI.exe, the encoded texture looks almost same as the original input png. open the astc version in ImageViewer, it will looks much lighter open the etc2 version in ImageViewer, it will looks much greener

kopaka1822 commented 2 years ago

I will try to take a look at this on the weekend

powof2 commented 2 years ago

Here is what they look in imageviewer: lena

ps. I mean ImageViewer and not TextureViewer in the picture.

kopaka1822 commented 2 years ago

Hello,

the etc2 version in ImageViewer, it will looks much greener

I fixed this. The red and blue channels were swapped, that's why this issue occurred. The problem is that I cannot really test non directx formats with my unit tests. So it looks like my compression tool (compressonator) swapped the channels when saving the image and then swapped them again when loading (that's why this issue didn't occur to me yet).

the astc version in ImageViewer, it will looks much lighter

I could not reproduce that. Can you tell me which exact format did not work? I used ASTC 4x4 srgb (vulkan) to test this but I had no issue (Are you sure that you did not use linear instead of srgb?).

I added the updated files as attachment, so that you can test if the issues were solved. (for version 3.5) imageloader.zip

powof2 commented 2 years ago

Hi, I thinks the etc2 looks better because they both looks lighter: iv-test what they look in PVRTexTool:

ptt-test

more info: the astc encode format : ASTC_5x5, sRGB, unsigned normalized byte the etc2 endode format : etc2_RGB, sRGB, unsgiend normalied byte

here is the images used for testing: lena-test.zip

kopaka1822 commented 2 years ago

Hello, when i open your lena-astc5x5.ktx or etc file in my PVRTexTool (which I downloaded yesterday) I get exactly the same issue: image

I think there might have been an issue in the older versions of the tool which they fixed by now. If I use my PVRTexTool to create to create an ASTC file, it works in the TexTool and in the ImageViewer.

PS: I would also recommend you to use one of the supercompressed formats (BASISU ETC1S/UASTC), because they will compress the file on CPU and GPU, so you also save some disk space (this requires .ktx2 file formats)

powof2 commented 2 years ago

yes, I use older version of PVRTexTool, because the new one has errors when running in command line (accept astc_4x4 and astc_8x8 only, older version has no this problem).

I guess it may be a problem of the software decoder, i'll check it out. and as for ktx2, i'll check it out as well.

thank you for the great tool.