//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // //===========================================================================// #include "tier0/platform.h" #include "bitmap/float_bm.h" #include "mathlib/mathlib.h" #include "tier2/tier2.h" #include "bitmap/tgaloader.h" #define NEIGHBORHOOD_SIZE 5 void SynthesizeTexture(FloatBitMap_t & output, FloatBitMap_t const & input) { // init output with histogram-equalized random pixels output.InitializeWithRandomPixelsFromAnotherFloatBM(input); // build image pyramids FloatImagePyramid_t input_pyramid(input,PYRAMID_MODE_GAUSSIAN); FloatImagePyramid_t output_pyramid(output,PYRAMID_MODE_GAUSSIAN); // now, synthesize texture from lowest res to highest for(int level=min(input_pyramid.m_nLevels,output_pyramid.m_nLevels)-2;level>=0;level--) { FloatBitMap_t & output=*(output_pyramid.Level(level)); FloatBitMap_t & output0=*(output_pyramid.Level(level+1)); FloatBitMap_t & input=*(input_pyramid.Level(level)); FloatBitMap_t & input0=*(input_pyramid.Level(level+1)); if ( (input.Width < NEIGHBORHOOD_SIZE*3) || (input.Height < NEIGHBORHOOD_SIZE*3) ) { printf("skip level %d\n",level); continue; } // now, synthesize each pixel for(int yloop=0;yloop