//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // //===========================================================================// #include #include "bitmap/float_bm.h" #include "mathlib/mathlib.h" #include #define N_TEXTURES_OUTPUT 3 #define TEXTURE_TO_TEXTURE_SCALE 8.0 #define BASE_SCALE 0.25 static float Truncate8( float f ) { uint8 px= (uint8) min(255.0, (f*255.0)); return px*(1.0/255.0); } static float ErrorWeights[]={ 0.3, 0.59, 0.11 }; void main(int argc,char **argv) { InitCommandLineProgram( argc, argv ); if ( argc==3) { FloatBitMap_t src_texture; src_texture.LoadFromPFM( argv[1] ); float sfactor=atof(argv[2]); // we will split the float texture into 2 textures. FloatBitMap_t output_textures[N_TEXTURES_OUTPUT]; for(int o=0; o curscale) err *=2; px_error[o] += ErrorWeights[o] * err; } sum_error += px_error[o]; curscale *= TEXTURE_TO_TEXTURE_SCALE; } // now, set the weight for each map based upon closeness of fit between the scales for(int o=0; o