Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 3.23 KB

README.md

File metadata and controls

63 lines (47 loc) · 3.23 KB

klafsa

klafsa is a quick hack but hopefully useful tool for mass converting textures in glTF files from JPEG/PNG to compressed formats using external tools such as:

'klafsa' means something like 'squelch' in Swedish. I wanted to use a word that has perhaps not been used for texture compression tools previously, and the space of English words is rather heavily used already.

Setup

Make sure one of the above tools is in your PATH. Usual Rust cargo tooling can be used to build / install klafsa and then command-line usage is as follows:

klafsa 0.1.0
Texture compression tool for converting JPEG/PNG to various compressed formats

USAGE:
    klafsa [OPTIONS] <SUBCOMMAND>

OPTIONS:
    -b, --backend <BACKEND>        Which tool to use for compression [default: toktx] [possible
                                   values: basisu, kram, toktx]
        --codec <CODEC>            Which codec to use for compression [possible values: astc,
                                   astc4x4, astc5x5, astc6x6, astc8x8, bc1, bc3, bc4, bc5, bc7,
                                   etc1s, etc2r, etc2rg, etc2rgb, etc2rgba, uastc]
        --container <CONTAINER>    Which container format to use [possible values: basis, ktx2]
    -h, --help                     Print help information
    -V, --version                  Print version information

SUBCOMMANDS:
    gltf    Converts all JPEG/PNG textures referred to by a JSON-format glTF
    help    Print this message or the help of the given subcommand(s)

The following would parse model.gltf to identify textures compressed with JPEG/PNG and use the kram tool to convert them to bc7 in ktx2, also outputting a model_bc7_ktx2.gltf file next to the original:

klafsa gltf --backend kram --codec bc7 --container ktx2 /path/to/model.gltf

TODO

  • all codecs and containers for each backend
    • basisu
    • kram
    • toktx
  • single command to convert to all formats
  • in-process compression, as-in without spawning separate processes to allow usage in more online use cases?
  • glb / embedded glTF support
  • support converting individual image files outside of a gltf

License

klafsa is free and open source! All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.