Pfm2tgas
Info
pfm2tgas is a command-line utility designed to convert Portable Float Map (PFM) files into multiple Targa (TGA) image files. The tool is particularly useful for processing high dynamic range (HDR) textures by decomposing them into multiple lower dynamic range representations at different scale levels.
Features
- Converts PFM files to TGA format
- Generates 3 output textures at different scale levels
- Applies configurable scale factors to input data
- Uses weighted error calculation with different weights per texture level
- Automatic alpha channel generation based on error distribution
- 8-bit quantization with proper clamping
Technical Details
The tool uses a multi-scale decomposition approach where:
- Base scale: 0.25
- Texture-to-texture scale factor: 8.0
- Error weights: Output texture levels weighted as (0.3, 0.59, 0.11) for texture 0, 1, and 2 respectively
- Output textures: 3 levels with progressively higher scale factors (0.25, 2.0, 16.0)
The algorithm calculates per-pixel errors across different scale levels, with error values doubled when the source pixel exceeds the current scale level. Alpha weights are assigned based on normalized error distribution (lower error = higher alpha), enabling efficient representation of high dynamic range data across multiple textures.

sum_error
equals zero may not set the correct output texture's alpha channel.Usage
Syntax
pfm2tgas <input.pfm> <scale_factor>
Parameters
- input.pfm
- The input Portable Float Map file to be processed
- scale_factor
- A floating-point multiplier applied to the input texture values
Output
The tool generates three TGA files with the following naming convention:
- input_0.tga - First scale level (finest detail)
- input_1.tga - Second scale level (medium detail)
- input_2.tga - Third scale level (coarsest detail)
Each output file contains:
- RGB channels: Quantized pixel data at the respective scale level
- Alpha channel: Weight values indicating the confidence/contribution of that scale level for each pixel
Examples
# Convert a PFM file with scale factor of 2.0 pfm2tgas lighting.pfm 2.0 # Convert with a smaller scale factor for darker images pfm2tgas environment.pfm 0.5 # Process a PFM file with unity scale pfm2tgas texture.pfm 1.0
|