MCPcopy Create free account
hub / github.com/carbonengine/trinity / CompressNormalMap3Dc

Function CompressNormalMap3Dc

trinity/Tr2DxtCompressor.cpp:795–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793}
794
795void CompressNormalMap3Dc( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel )
796{
797 uint8_t block[64];
798 uint8_t normalMin[4];
799 uint8_t normalMax[4];
800
801 uint8_t** outData = &outBuf;
802
803 for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 )
804 {
805 if( cancel )
806 {
807 return;
808 }
809 for( int i = 0; i < width; i += 4 )
810 {
811
812 ExtractBlock( inBuf + i * 4, width, block );
813
814 GetMinMaxNormalsBBox( block, normalMin, normalMax );
815 InsetNormalsBBox3Dc( normalMin, normalMax );
816
817 // Write out Nx as an alpha channel.
818 EmitByte( normalMax[0], outData );
819 EmitByte( normalMin[0], outData );
820 EmitAlphaIndicesForNormals( block, 0, normalMin[0], normalMax[0], outData );
821
822 // Write out Ny as an alpha channel.
823 EmitByte( normalMax[1], outData );
824 EmitByte( normalMin[1], outData );
825 EmitAlphaIndicesForNormals( block, 1, normalMin[1], normalMax[1], outData );
826 }
827 }
828
829 outputBytes = *outData - outBuf;
830}
831
832bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt,
833 const uint8_t* inBuf,

Callers 1

Tr2DxtCompressSurfaceFunction · 0.85

Calls 5

ExtractBlockFunction · 0.85
GetMinMaxNormalsBBoxFunction · 0.85
InsetNormalsBBox3DcFunction · 0.85
EmitByteFunction · 0.85

Tested by

no test coverage detected