KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
874 stars 229 forks source link

Can't compress a 16-bit input texture with UASTC: "Operation not allowed in the current state". #360

Closed zeux closed 3 years ago

zeux commented 3 years ago

I'm getting the error when converting Fabric_normal.png from ToyCar example in glTF-Sample-Models with the following command line:

> "C:\Program Files\KTX-Software\bin\toktx.exe" --t2 --2d --genmipmap --nowarn --uastc 1 --uastc_rdo_q 0.29 --uastc_rdo_d 1024 --zcmp 9 --linear -- Fabric_normal.ktx2 Fabric_normal.png
toktx failed to compress KTX file "Fabric_normal.ktx2"; KTX error: Operation not allowed in the current state.

The following, simpler, command-line also reproduces the same issue:

> "C:\Program Files\KTX-Software\bin\toktx.exe" --t2 --2d --uastc 1 -- Fabric_normal.ktx2 Fabric_normal.png

When using --bcmp instead of --uastc, the conversion completes successfully with the following warning:

toktx warning: Rescaling 16-bit image to 8 bits.

I've attached the texture that has the issue.

Fabric_normal

donmccurdy commented 3 years ago

I've run into the same issue in glTF-Transform, https://github.com/donmccurdy/glTF-Transform/issues/181. Neither I, nor the users of that tool, are very familiar with the various types of PNG files, so if it's possible for KTX-Software to handle this or report a more actionable error that would be helpful. 🙂

zeux commented 3 years ago

Err I thought the PR was already merged 😅 Will just keep this closed since that should happen imminently presumably.

MarkCallow commented 3 years ago

Just added a test to the PR to make sure this doesn't happen again. Completed PR is in CI now.