diff --git a/Scripts/README.md b/Scripts/README.md index 5e167b7..871ca50 100644 --- a/Scripts/README.md +++ b/Scripts/README.md @@ -11,15 +11,16 @@ All files require python3 to be installed. ## Usage ### ddscompress.py -usage: `ddscompress.py [-h] [--convertcmd CMD] [--compresscmd CMD] [files ...]` +usage: `ddscompress.py [-h] [--format {auto,DXT1,DXT5}] [--convertcmd CMD] [--compresscmd CMD] [files ...]` Converts any number of files to `.dds` format, automatically choosing dxt1 or dxt5 depending on if the source image has anything in its alpha channel. Designed to be used with a glob, e.g: `ddscompress.py *.png` -###### positional arguments: +##### positional arguments: * `files`: input texture files -###### optional arguments: +##### optional arguments: * `-h, --help `: show this help message and exit +* `--format {auto,DXT1,DXT5}`: output texture format (default: auto) * `--convertcmd CMD`: name of imagemagick's convert tool (default: `convert`) * `--compresscmd CMD`: name of the nvidia dds compress tool (default: `nvcompress`) @@ -28,10 +29,10 @@ usage: `ddsdecompress.py [-h] [--decompresscmd CMD] [files ...]` Converts any number of files to `.tga` from `.dds`. Designed to be used with a glob, e.g: `ddsdecompress.py *.dds` -###### positional arguments: +##### positional arguments: * `files`: input dds files -###### optional arguments: +##### optional arguments: * `-h, --help`: show this help message and exit * `--decompresscmd CMD`: name of the nvidia dds decompress tool (default: `nvdecompress`) @@ -40,10 +41,10 @@ usage: `ddsck.py [-h] [--convertcmd CMD] [--infocmd CMD] [files ...]` Checks any number of dds files for common issues, including formats not supported by KSP, and DXT5 textures that don't use the alpha channel. Designed to be used with a glob, e.g: `ddsck.py *.dds` -###### positional arguments: +##### positional arguments: * `files`: input dds files -###### optional arguments: +##### optional arguments: * `-h, --help`: show this help message and exit * `--convertcmd CMD`: name of imagemagick's convert tool (default: `convert`) * `--infocmd CMD`: name of the nvidia dds info tool (default: `nvddsinfo`) \ No newline at end of file diff --git a/Scripts/ddscompress.py b/Scripts/ddscompress.py index 71e7b12..9f1a104 100755 --- a/Scripts/ddscompress.py +++ b/Scripts/ddscompress.py @@ -9,6 +9,7 @@ import dds parser = argparse.ArgumentParser(description="Converts any number of textures to dds format. automatically chooses dxt1 or dxt5 depending on if the source image has anything in its alpha channel.") parser.add_argument('files', type=str, nargs='*', help = "input texture files") +parser.add_argument('--format', type=str, choices=['auto', 'DXT1', 'DXT5'], default = "auto", help = "output texture format (default: %(default)s)") parser.add_argument('--convertcmd', type=str, metavar='CMD', default="convert", help="name of imagemagick's convert tool (default: %(default)s)") parser.add_argument('--compresscmd', type=str, metavar='CMD', default="nvcompress", help="name of the nvidia dds compress tool (default: %(default)s)") @@ -23,13 +24,13 @@ with tempfile.TemporaryDirectory() as tempDir: file = os.path.abspath(argv) tmpOutput = os.path.join(tempDir, os.path.basename(file)) output = os.path.splitext(file)[0] + ".dds" - - alpha = dds.alpha(file) + dds.flip(file, tmpOutput) - - if alpha < 255: + + if (args.format == "auto" and dds.alpha(file) < 255) or args.format == "DXT5": format = "-bc3" else: format = "-bc1" + dds.nvcompress(format, tmpOutput, output) os.remove(file) \ No newline at end of file