akb825/Cuttlefish

image from TGA RGBA -> BC7 getting a weird transformation

Closed this issue · 3 comments

I honestly have no idea what is going on. I am using the latest windows binary with commands:
./cuttlefish.exe -i INPUT.tga -j -m -f BC7 -Q highest -v -o OUTPUT.dds

image

Here are the files if you want to take a look.
bin.zip

I believe this is a bug with the viewer you're using. I tried both RenderDoc and Visual Studio and both view OUTPUT.dds correctly. For example, see this screenshot from RenderDoc:
image

I installed IrfanView based on your screenshot and was able to see the same error you did. However, given that two other tools display the .dds correctly, I'm certain that the bug here lies with IrfanView.

I did a bit more troubleshooting, and I think I corrupted the TGA's header a tiny bit (bad height x width).
I think the TGA header passed some bad info to the DDS header in a non-essential way, because it only threw off irfan and the game I was trying to read it into.

So cuttlefish is functioning as intended, sorry for the false alarm! Thank you for looking into it though.

Taking a quick look I'm not sure if there's a corrupt size. However, the width (4121) isn't a multiple of the BC7 block size (4x4), so most likely both IrfanView and the engine aren't handling this properly. The texture data will always be a multiple of the block size, but any extra pixels are discarded when displaying. For example, if IrfanView decodes 4124 pixels each line and displays as 4121 pixels (without discarding the remainder) that would explain the skew. The game engine may similarly be attempting to incorrectly round the size.

Either way these are bugs with the IrfanView and the engine, but the easiest way to avoid them is to make sure your image size is a multiple of 4.