TimvanScherpenzeel / texture-compressor

CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.
MIT License
200 stars 40 forks source link

Enable Vertical flip #5

Closed ksabariraj closed 6 years ago

ksabariraj commented 6 years ago

HI,

Thanks for the tool.

Is any options to enable vertical flip and disable MIPMaps?

Thanks, Sabari.

TimvanScherpenzeel commented 6 years ago

By default only the ASTC texture is flipped beforehand (as it flips the texture internally during compression) in order to restore it to its initial position.

At the moment no mipmapping should be generated during compression though I am working on exposing it through a flag in https://github.com/TimvanScherpenzeel/texture-compressor/issues/3.

In general the texture you pass to the tool should be in a final state (meaning a power of two and flipped in the direction you would like).

When using PVR or ETC you can pass the vertical flip flag directly to the tool using -f "flip y".

Meaning that an example command would look like node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-pvrtc2BPP.ktx -t pvr -c pvrtc1 -f "flip y".

ksabariraj commented 6 years ago

Thanks for your time and update.

Now I am getting "not recognized" error.

Output: Commandline argument "-flip" not recognized

TimvanScherpenzeel commented 6 years ago

Which format are you trying to compress? You need to pass -f "flip y", with the -f in front. This only works for PVR and ETC.

ksabariraj commented 6 years ago

Oh sorry. I trying for ASTC. After conversion the texture is not loading properly.

FYI, I am using Three.js KTXLoader.

TimvanScherpenzeel commented 6 years ago

No problem. I'll have a look at KTXLoader and see if I can find the issue.

On what device are you testing?

TimvanScherpenzeel commented 6 years ago

I've tried to replicate your issue on the Samsung Galaxy S8+ (which supports ASTC) with both example-astc-4x4.ktx and example-astc-8x8.ktx. This works fine.

screen shot 2018-04-11 at 15 02 15

To check if your device has the ASTC extension please check the supportedExtensions section in webglFeatures on https://timvanscherpenzeel.github.io/detect-features/ on the actual device.

ksabariraj commented 6 years ago

Android Galaxy J5.

TimvanScherpenzeel commented 6 years ago

Then it is very likely the ASTC extension is not supported on your device. Only recent high end Android devices support it. ETC1 will likely work with your device (please note that it does not support alpha).

TimvanScherpenzeel commented 6 years ago

So it is loading correctly but the texture is flipped..

Would you be able to manually flip the texture before passing it through the texture compressor?

I think the entire set up I created for flipping the ASTC texture before passing it through the texture compressor might be redundant but this does require further research on my part. I can remember there was a good reason why I implemented it in the first place. If it is not redundant I'll add a new flag to support vertical flipping.

ksabariraj commented 6 years ago

Sure, I will try to flip the texture. And adding new flag to support vertical flipping will really help.

I have a question: I used Frontside material, if I flipped will it cause any issue?

Thanks again.

TimvanScherpenzeel commented 6 years ago

Just some notes, mostly for myself:

For some reason the KTXLoader of Three.js seems to be flipping the texture (in the correct orientation). This is an unflipped version of example-astc-8x8.ktx.

astc texture orientation issues

The unflipped file example-astc-8x8-unflipped.ktx.zip

TimvanScherpenzeel commented 6 years ago

Added flip flag in https://github.com/TimvanScherpenzeel/texture-compressor/pull/8. The flag is disabled by default but can be passed using -y or -flipy.

I've also replaced my previous custom loader with the Three.js implementation.

Thank you for your suggestion and highlighting the issue. I'll consider this issue closed. If you have any other issues or suggestions feel free to open up a new issue.

ksabariraj commented 6 years ago

Thanks a lot. Its working great 👍