diff --git a/TextureFileCreater.cpp b/TextureFileCreater.cpp index 310bd34..e52f205 100644 --- a/TextureFileCreater.cpp +++ b/TextureFileCreater.cpp @@ -47,10 +47,10 @@ bool ToILType(ILuint &type,const uint8 bits,const ColorDataType cdt) { constexpr ILuint target_type[3][(uint)ColorDataType::END-1]= { - //UNORM SNORM UINT SINT, USCALE,SSCALE, UFLOAT SFLOAT - {IL_UNSIGNED_BYTE, IL_BYTE, IL_UNSIGNED_BYTE, IL_BYTE, 0,0, 0, 0}, - {IL_UNSIGNED_SHORT, IL_SHORT, IL_UNSIGNED_SHORT, IL_SHORT, 0,0, IL_HALF, IL_HALF}, - {IL_UNSIGNED_INT, IL_INT, IL_UNSIGNED_INT, IL_INT, 0,0, IL_FLOAT, IL_FLOAT} + //UNORM SNORM UINT SINT, USCALE,SSCALE, UFLOAT SFLOAT + /* 8 */{IL_UNSIGNED_BYTE, IL_BYTE, IL_UNSIGNED_BYTE, IL_BYTE, 0,0, 0, 0}, + /* 16 */{IL_UNSIGNED_SHORT, IL_SHORT, IL_UNSIGNED_SHORT, IL_SHORT, 0,0, IL_HALF, IL_HALF}, + /* 32 */{IL_UNSIGNED_INT, IL_INT, IL_UNSIGNED_INT, IL_INT, 0,0, IL_FLOAT, IL_FLOAT} }; if(bits<=8 )type=target_type[0][(uint)cdt-1];else diff --git a/TextureFileCreaterRGB.cpp b/TextureFileCreaterRGB.cpp index a99f286..966d956 100644 --- a/TextureFileCreaterRGB.cpp +++ b/TextureFileCreaterRGB.cpp @@ -21,6 +21,25 @@ public: } } + // Bit depth Sign bit present Exponent bits Mantissa bits + // 32 Yes 8 23 + // 16 Yes 5 10 + // 11 No 5 6 + // 10 No 5 5 + + void RGB16FtoB10GR11UF(uint32 *target,uint16 *src,uint size) + { + for(uint i=0;i>4; + + ++target; + src+=3; + } + } + public: bool Write() override @@ -48,6 +67,16 @@ public: return TextureFileCreater::Write(rgb565); } + else if(fmt->format==ColorFormat::B10GR11UF) + { + void *origin_rgb=image->GetRGB(IL_HALF); + + AutoDelete b10gr11=new uint32[image->pixel_total()]; + + RGB16FtoB10GR11UF(b10gr11,(uint16 *)origin_rgb,image->pixel_total()); + + return TextureFileCreater::Write(b10gr11); + } else { LOG_ERROR(OS_TEXT("Don't support this RGB format")); diff --git a/pixel_format.cpp b/pixel_format.cpp index 4696f5f..a710ca1 100644 --- a/pixel_format.cpp +++ b/pixel_format.cpp @@ -46,7 +46,8 @@ namespace hgl {ColorFormat::RGB32F, "RGB32F", 3,{'R','G','B', 0 },{32,32,32, 0},ColorDataType::SFLOAT}, {ColorFormat::RGBA32U, "RGBA32U", 4,{'R','G','B','A'},{32,32,32,32},ColorDataType::UINT}, {ColorFormat::RGBA32I, "RGBA32I", 4,{'R','G','B','A'},{32,32,32,32},ColorDataType::SINT}, - {ColorFormat::RGBA32F, "RGBA32F", 4,{'R','G','B','A'},{32,32,32,32},ColorDataType::SFLOAT} + {ColorFormat::RGBA32F, "RGBA32F", 4,{'R','G','B','A'},{32,32,32,32},ColorDataType::SFLOAT}, + {ColorFormat::B10GR11UF, "B10GR11UF", 3,{'B','G','R', 0 },{11,11,11, 0},ColorDataType::UFLOAT} }; constexpr uint PixelFormatCount=sizeof(pf_list)/sizeof(PixelFormat); diff --git a/pixel_format.h b/pixel_format.h index c08b448..949b598 100644 --- a/pixel_format.h +++ b/pixel_format.h @@ -33,6 +33,7 @@ enum class ColorFormat RGBA32U, RGBA32I, RGBA32F, + B10GR11UF, END };//enum class ColorFormat