Resize or Generate mipmaps for RGB data

Good day!



I am trying to load uncompresssed data to texture, resize, generate mipmaps and compress in some of ETC formats, problem is that when source data is in RGB format, resizing and mpmap generation return false, if source is RGBA everything fine.



PixelType pt;
if ( mTex->format() == RGB ) // Get current format
pt = PixelType( 'r', 'g', 'b', 0, 8, 8, 8, 0 );
else if ( mTex->format() == RGBA )
pt = PixelType('r', 'g', 'b', 'a', 8, 8, 8, 8);
else{
qCritical("ETCnCompressor::compress() Unknown pixel format or compressed texture!");
return false;
}

EPVRTPixelFormat newFormat = getPVRFormat( format ); // Target format
if ( newFormat == ePVRTPF_NumCompressedPFs ){
qCritical("ETCnCompressor::compress() Bad compression format");
return false;
}

PVRTextureHeaderV3 pvrHeader;
pvrHeader.u32Version = PVRTEX_CURR_IDENT;
pvrHeader.u32Flags = 0;
pvrHeader.u64PixelFormat = pt.PixelTypeID;
pvrHeader.u32ColourSpace = ePVRTCSpacelRGB;
pvrHeader.u32ChannelType = ePVRTVarTypeUnsignedByteNorm;
pvrHeader.u32Width = mTex->width();
pvrHeader.u32Height = mTex->heigth();
pvrHeader.u32Depth = 1;
pvrHeader.u32NumSurfaces = 1;
pvrHeader.u32NumFaces = 1;
pvrHeader.u32MIPMapCount = 1;
pvrHeader.u32MetaDataSize = 0;
CPVRTextureHeader h( pvrHeader );
CPVRTexture tex( h, mTex->level( 0 )->data() );

bool ok = false;
ok = Resize( tex,
qMin( maxSize, nearestPowerOf2( tex.getWidth () ) ),
qMin( maxSize, nearestPowerOf2( tex.getHeight() ) ),
tex.getDepth(),
eResizeCubic
);

if ( !ok ){
qWarning("ETCnCompressor::compress() Fail to resize image" );
}

ok = false;
ok = GenerateMIPMaps( tex, eResizeCubic );
if ( !ok ){
qWarning("ETCnCompressor::compress() Fail to generate mipmaps");
}


Am i doing smth wrong or there is no support resize for RGB data?

Hi JekaS,



PVRTexLib currently only supports these operations for RGBA formats in either UnsignedNormalised RGBA8888, RGBA16161616 or RGBA32323232, or RGBA full float. So unfortunately it’s returning false for all of the other formats because it cannot handle them. I’d suggest you simply use the transcode function to turn the RGB data into RGBA, then carry on as normal. Future versions of the library will support these operations on all uncompressed formats, but for now I’m afraid that you’ll have to do the transcode.



Regards,

Tobias