mipgen generates mipmaps for textures down to the 1x1 level, with support for various filtering kernels and output formats.
Usage
<output_pattern> is a printf-style pattern. For example, mip%02d.png generates mip01.png, mip02.png, etc.
Mip level 0 is not generated since it is the original image.
Supported Input Formats
- PNG (8 and 16 bits)
- JPEG
- Radiance (
.hdr) - Photoshop (
.psd, 16 and 32 bits) - OpenEXR (
.exr) - And other formats supported by stb_image and tinyexr
Options
Output Format
--format, -f <format>- Specify output file formatpng- PNG (default for LDR)hdr- Radiance HDRexr- OpenEXRpsd- Photoshopdds- DirectDraw Surfacektx- KTX1 containerktx2- KTX2 container (with Basis compression)rgbm- RGBM encoded PNG- If omitted, format is inferred from output pattern extension
Filter Kernels
--kernel, -k <filter>- Specify filter kernel type (default:lanczos)box- Box filter (fastest, lowest quality)nearest- Nearest neighborhermite- Hermite filtergaussian- Gaussian filternormals- Gaussian filter optimized for normal mapsmitchell- Mitchell-Netravali filterlanczos- Lanczos filter (default, high quality)min- Minimum filter
Compression
--compression, -c <compression>- Format-specific compression:- KTX/PNG/Radiance: Ignored
- KTX2:
uastc,etc1s,uastc_normals,etc1s_normals - Photoshop:
16(default),32 - OpenEXR:
RAW,RLE,ZIPS,ZIP,PIZ(default) - DDS:
8,16(default),32
Color Space
--linear, -l- Specifies that source image is linear- Converts to floats without gamma transformation
- Use for normal maps, metallic/roughness maps, etc.
Channel Control
--grayscale, -g- Create a single-channel image- Extracts the first channel only
--add-alpha- Add a fourth channel filled with 1.0- Use when source has 3 channels but you need 4
--strip-alpha- Ignore the alpha component- Use to convert RGBA to RGB
Mip Level Control
--mip-levels, -m <N>- Specifies number of mip levels to generate0(default) generates all levels down to 1x1- Otherwise generates N-1 levels (excluding the base level)
Output Options
--page, -p- Generate HTML page for review (mipmaps.html)- Creates a visual gallery of all mip levels
--quiet, -q- Suppress console output
Examples
Generate PNG mipmaps with Lanczos filter
mip_001.png, mip_002.png, mip_003.png, etc.
Generate KTX2 with UASTC compression
Normal map processing
Grayscale mipmaps with Hermite filter
Generate with review page
mipmaps.html for visual inspection.
EXR output with compression
Limit mip levels
KTX1 container for deployment
Strip alpha channel
Filter Kernel Guide
For Color/Albedo Textures
- Lanczos (default): Best quality, sharp results
- Mitchell: Good balance of sharpness and smoothness
- Hermite: Smoother, less ringing than Lanczos
For Normal Maps
- normals: Specially designed for normal maps
- Normalizes vectors after filtering
- Prevents normal vectors from losing length
For Other Data
- Box: Fast, for non-critical textures
- Gaussian: Smooth falloff
- Min: Preserve minimum values (useful for some masks)
KTX2 Compression
KTX2 uses Basis Universal compression:UASTC (Universal ASTC)
- Higher quality
- Larger file size than ETC1S
- Faster encoding
- Best for high-quality assets
ETC1S (ETC1 Subset)
- Smaller file size
- Lower quality than UASTC
- Slower encoding (better compression)
- Best for mobile/web deployment
Normal Map Compression
- Optimized for normal map data
- Use with
--linearflag - Available for both UASTC and ETC1S
Output Pattern
The output pattern uses printf-style formatting:%d- Decimal number:mip1,mip2,mip3%02d- Zero-padded 2 digits:mip01,mip02,mip03%03d- Zero-padded 3 digits:mip001,mip002,mip003
Best Practices
For Runtime Textures
- Use KTX containers for efficient loading
- Enable compression for reduced memory/bandwidth
- Choose appropriate filter for texture type
For Normal Maps
- Always use
--linearflag - Use
--kernel=normalsfilter - Consider normal-specific compression for KTX2
For Alpha Channels
- Use
--add-alphawhen you need a fully opaque alpha channel - Use
--strip-alphato reduce file size when alpha isn’t needed
For Web/Mobile
- Smallest file size
- Good enough quality for most cases
- Fast decode on GPU
Troubleshooting
”Unable to open image”
Verify the input file exists and is in a supported format.”Output pattern is too long”
Shorten your output path or filename.Mipmaps look too blurry
Try a sharper filter likelanczos or mitchell.
Normal maps look incorrect
Make sure to use:Help
--help, -h- Print help message--license, -L- Print copyright and license information