Skye Cuillin - Texture Tools
By Vilem Otte
engine
Texture tool for Skye Cuillin engine used for BC texture compression, (pre-)generation of mip maps in various ways. The software can be either run with a window, showing real time preview of how compressed image looks like, or in a headless way called from command line.
Skye Cuillin - Texture Tools screenshot
Compression formats
Texture Tools's main purpose is to allow for compression into BCn textures. Supported compression formats are:
BC1
BC1 stores RGB data, possibly supports alpha channel through degeneracy. Uses 8-bytes to store 4x4 block, having average data rate of 0.5 bytes per pixel. The block consists of 2 endpoints, both having 2 bytes (in RGB565 format).
The palette for block then consists of 4 elements palette - generated from the endpoints (if 1st and 2nd endpoint were laid on line - the elements would be at 1st endpoint, at 1/3rd and 2/3rd points on the line from 1st to 2nd and 2nd endpoint). The 1st endpoint should be smaller number in RGB space than 2nd, otherwise it is degenerate sample (which can be used to encode 1-bit alpha).
The indexes into palette are 2 bits per pixel - requiring remaining 4 bytes from the block.
This format should be used to store F.e. color maps without requirement for transparency
BC2
BC2 stores RGBA data and is combined format - uses BC1 to store RGB part and 4-bit per pixel to store Alpha part. Uses 16-bytes to store 4x4 block.
BC3 should be preferred over BC2
BC3
BC3 stores RGBA data and is combined format - uses BC1 to store RGB part and BC4 to store Alpha part. Uses 16-bytes to store 4x4 block.
This format should be used to store F.e. color maps requiring alpha channel (transparency)
BC4
BC4 stores grayscale image - using 8-bytes to store 4x4 block. The block consists of 2 endpoints, both having 1 byte (in R8 format).
The palette for block then consists of 8 elements palette (1st and 8th being endpoints, remaining uniformly splitting the line between endpoints).
The indexes into palette are 3 bits per pixel - requiring remaining 6 bytes from the block.
This format should be used to store F.e. roughness maps or height maps
BC5
BC5 stores RG data and is combined format - uses BC4 to store R and another BC4 to store G channel. Uses16 bytes to store 4x4 block.
This format should be used to store F.e. tangent-space normal maps
BC6H
BC6H stores RGB data in HDR format. Uses 16-bytes to store 4x4 block. Each block allows for different mode (having various number of endpoints, various palette size, etc.). The stored data are in 16-bit half-precision floating-point data.
This format should be used to store F.e. environment maps, light maps
Supported compression options:
There are various compression options supported - used for different types of maps.
Dithering
Defines whether dithering should be used with compression. This can increase quality of compressed image depending on what kind of data is compressed.
Generate Mipmaps
Defines whether mipmaps should be generated for an image prior to compression and used. Default mipmap generation algorithm is using average of 2x2 block to calculate pixel in higher mipmap level. These mipmaps are then stored in file and later used by the engine. Files with generated mipmaps do NOT generate them when loaded anymore.
Alpha Mipmaps
Overrides default mipmap calculation with specific way to calculate mipmaps to retain percentage of coverage from top mipmap level. This ensures that alpha-tested (or sample-alpha-to-coverage) textures mapped on geometry at distance doesn't lose volume. The results are demonstrated in next image with alpha keyed to be bright pink (notice how 'washed out' is mipmap level 7 in middle image when not using alpha mipmaps, and how mode dense it is in the right image using alpha mipmaps):
Alpha mipmaps example - from left to right: Original image mipmap level 0, Image at mipmap level 7 without alpha mipmaps, Image at mipmap level 7 with alpha mipmaps
Note: Does not work with normal mipmaps generation
Normal Mipmaps
Overrides default mipmap calculation with specific way to re-normalize vector after each mipmap level computation. This ensures that slopes in normal map are retained. On an example image notice how slopes are much better defined in the right image compared to middle one. The slopes should ideally match original image on the left (which the right image matches a lot more closely).
Normal mipmaps example - from left to right: Original image mipmap level 0, Image at mipmap level 4 without normal mipmaps, Image at mipmap level 4 with normal mipmaps
Note: Does not work with alpha mipmaps generation
Usage
The standard application can be used directly - where images can be opened by hand, processed and saved in output format. The headless mode is called through command line and uses the following arguments:
--input, -i
Path to input image file (*.*)
--output, -o
Path to output image file (*.sctex)
--format, -f
Format to use for compression (0 - BC1, 1 - BC2, 2 - BC3, 3 - BC4, 4 - BC5)
--dithering, -d
Use dithering to improve
--mipmaps, -m
Path to input image file
--alpha, -a
Path to input image file
--normals, -n
Path to input image file
--exposure, -e
Exposure value - decimal number, default is 1.0
The headless mode then processes everything and exits once computation is done.
Both variants write log file providing base information and possible issues/errors.