#include #include #include #include #include using namespace hgl; using namespace hgl::util; #if HGL_OS == HGL_OS_Windows #define std_cout std::wcout #else #define std_cout std::cout #endif// namespace hgl { void RGB2YUV(uint8 *y,uint8 *u,uint8 *v,const uint8 *rgb,const uint w,const uint h); void normal_compress(uint8 *x,uint8 *y,const uint8 *rgb,const uint count); template void MixRGB(T *rgb,const T *r,const T *g,const T *b,const uint count) { for(uint i=0;i void MixRGBA(T *rgba,const T *r,const T *g,const T *b,const T *a,const uint count) { for(uint i=0;i /C:BaseColor.png /N:Normal.png /M:Metallic.png /R:Roughness.png"<>1; const uint half_h=h>>1; if(metallic.isHas()) { metallic.ToGray(); metallic.Resize(half_w,half_h); } if(roughness.isHas()) { roughness.ToGray(); roughness.Resize(half_w,half_h); } uint8 *y,*u,*v,*nx,*ny; y=new uint8[w*h]; u=new uint8[half_w*half_h]; v=new uint8[half_w*half_h]; nx=new uint8[w*h]; ny=new uint8[w*h]; RGB2YUV(y,u,v,color.GetRGB(),w,h); normal_compress(nx,ny,normal.GetRGB(),w*h); // BaseColor Y + Normal XY { ILImage img; const OSString out_filename=OSString(argv[1])+OS_TEXT("_YN.png"); uint8 *pixels=new uint8[w*h*3]; MixRGB(pixels,y,nx,ny,w*h); img.Create(w,h,3,IL_UNSIGNED_BYTE,pixels); delete[] pixels; if(img.SaveFile(out_filename)) std_cout<(pixels,u,v,metallic.GetLum(),roughness.GetLum(),half_w*half_h); img.Create(half_w,half_h,4,IL_UNSIGNED_BYTE,pixels); delete[] pixels; if(img.SaveFile(out_filename)) std_cout<(pixels,u,v,metallic.GetLum(),half_w*half_h); img.Create(half_w,half_h,3,IL_UNSIGNED_BYTE,pixels); delete[] pixels; if(img.SaveFile(out_filename)) std_cout<(pixels,u,v,roughness.GetLum(),half_w*half_h); img.Create(half_w,half_h,3,IL_UNSIGNED_BYTE,pixels); delete[] pixels; if(img.SaveFile(out_filename)) std_cout<