**CNQ3 texture fixer** # Overview - This is a simple command-line tool that reads from one folder and outputs to a folder (either the same folder or another). - For each image file, it checks whether the image is compatible and properly sized for the original 1.32c Quake 3 executable. - It will then report the problem if there is any. - If enabled, it will write a new fixed version of the image. This is disabled with the `--readonly` option. - Image resampling is done - using good filters (Lanczos by default to favor sharpness), - with gamma correction (to do the math in something close to light-linear space) and - by taking repeat/clamp texture mode into account (currently assuming repeat for every image). # Limitations The tool currently only checks for the following image issues: - Resolution too high (can't load the map) - Progressive JPEG encoding (can't load the map) - Non-power of two resolutions (can load but slow and low quality image resampling happens) Resampling limitation: - The filter kernel width doesn't depend on the specific resize. - The filter kernel width is always an even number. Resampling quality should still beat the majority of applications despite this limitation. # Examples Quick-fixing a map: - Extract your .pk3 to ./mymap - `./cnq3texfix --indir=./mymap` - Generate a new .pk3 file from ./mymap Writing the fixes to a separate folder is useful to be able to open a folder/file/image diff tool: - `cnq3texfix.exe --indir=mymap --outdir=mymap_fixed` - `WinMergeU.exe /r mymap mymap_fixed` Read-only mode is useful to print the list of issues without taking any action: - `cnq3texfix.exe --indir=mymap --readonly` # Requirements You will need Windows or Linux. You can grab the latest version here: https://myt.playmorepromode.com/cnq3texfix/ # Compiling from source First grab the sources and navigate to the right folder: 1. `git clone https://bitbucket.org/CPMADevs/cnq3` 2. `cd cnq3/code/tools/cnq3texfix` Then compile: | OS | Compiler | Action | Output | |:--|:--|:--|:--| | Linux | GCC | `./build_gcc.sh` | ./cnq3texfix | | Windows | GCC | `build_gcc.cmd` | ./cnq3texfix.exe | | Windows | CL | `cnq3texfix.sln` -> compile | ./.bin/cnq3texfix.exe | # Command-line syntax If you run the executable without any argument, the help text will be displayed. ```text cnq3texfix --indir=dir [--outdir=dir] [--jpeg=quality] [--roundmode=mode] [--readonly] [--filter=resize] Arguments in brackets are optional. All arguments are case-insensitive: --indir=dir The folder with potentially 'bad' images. [--outdir=dir] If the output path is missing, the input directory is used. [--jpeg=quality] JPEG quality must be in the [1;100] range. Default: 100. [--roundmode=mode] Rounding mode must be one of: 'up', 'down', 'nearest'. Default: 'up'. [--readonly] Read-only mode disables writing to files. It reports work items only. [--filter=resize] Filter must be one of: 'Lanczos4', 'BlackmanHarris4', 'Lanczos3', 'BlackmanHarris3'. Default: 'Lanczos4'. Lanczos is the sharper filter. The digit is the support 'radius': 4 means the filter uses 8 pixels from the source along each axis. 3 means the filter uses 6 pixels from the source along each axis. ```