Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

DDS BC6 decoding has a broken blue channel

Open expenses opened this issue 3 years ago • 3 comments

I attempted to use the code in https://github.com/python-pillow/Pillow/blob/main/src/libImaging/BcnDecode.c for a project in order to decode BC6 textures. The red and green channels decoded correctly but the blue channel ended up being mangled somehow.

Here's the red channel of the image as displayed in renderdoc: 20220601_16h17m43s_grim

and here's the blue channel:

20220601_16h17m52s_grim

This results in an image that looks like this:

20220601_15h56m13s_grim

What are your OS, Python and Pillow versions?

  • OS: N/A
  • Python: N/A
  • Pillow: https://github.com/python-pillow/Pillow/commit/b261e179078a36adb030e029c9834d8c00dec4e0

expenses avatar Jun 01 '22 14:06 expenses

Would we be able to get a copy of the image itself?

radarhere avatar Jun 01 '22 22:06 radarhere

I've uploaded the source image (which is a cubemap with several mip levels) in 2 formats, .dds and .ktx2:

broken.zip

As the broken output .dds file is quite large (128mb) it exceeds the 25mb upload limit unless I make a non-trivial modification. Let me know if you'd like me to send that to you by another means though!

expenses avatar Jun 02 '22 12:06 expenses

Thanks for the image.

I'm not happy with it enough yet for a PR, but see what you think of https://github.com/radarhere/Pillow/commit/3b51e1cc498273d6c25afa8d29e60f77a9861518. It generates this from your image.

radarhere avatar Jun 04 '22 11:06 radarhere