start adding some support for ctx1 and other fixes.
This commit is contained in:
parent
1308795378
commit
2ea2aaaf4d
@ -27,3 +27,5 @@ NVIDIA Texture Tools version 0.9.4
|
||||
|
||||
NVIDIA Texture Tools version 0.9.5
|
||||
* Fixed PSNR formula.
|
||||
* Added support for arbitrary RGB formats.
|
||||
|
||||
|
@ -553,6 +553,70 @@ void BlockATI2::flip2()
|
||||
}
|
||||
|
||||
|
||||
void BlockCTX1::evaluatePalette(Color32 color_array[4]) const
|
||||
{
|
||||
// Does bit expansion before interpolation.
|
||||
color_array[0].b = 0x00;
|
||||
color_array[0].g = col0[1];
|
||||
color_array[0].r = col0[0];
|
||||
color_array[0].a = 0xFF;
|
||||
|
||||
color_array[1].r = 0x00;
|
||||
color_array[1].g = col0[1];
|
||||
color_array[1].b = col1[0];
|
||||
color_array[1].a = 0xFF;
|
||||
|
||||
color_array[2].r = 0x00;
|
||||
color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
|
||||
color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
|
||||
color_array[2].a = 0xFF;
|
||||
|
||||
color_array[3].r = 0x00;
|
||||
color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3;
|
||||
color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3;
|
||||
color_array[3].a = 0xFF;
|
||||
}
|
||||
|
||||
void BlockCTX1::decodeBlock(ColorBlock * block) const
|
||||
{
|
||||
nvDebugCheck(block != NULL);
|
||||
|
||||
// Decode color block.
|
||||
Color32 color_array[4];
|
||||
evaluatePalette(color_array);
|
||||
|
||||
// Write color block.
|
||||
for( uint j = 0; j < 4; j++ ) {
|
||||
for( uint i = 0; i < 4; i++ ) {
|
||||
uint idx = (row[j] >> (2 * i)) & 3;
|
||||
block->color(i, j) = color_array[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlockCTX1::setIndices(int * idx)
|
||||
{
|
||||
indices = 0;
|
||||
for(uint i = 0; i < 16; i++) {
|
||||
indices |= (idx[i] & 3) << (2 * i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Flip CTX1 block vertically.
|
||||
inline void BlockCTX1::flip4()
|
||||
{
|
||||
swap(row[0], row[3]);
|
||||
swap(row[1], row[2]);
|
||||
}
|
||||
|
||||
/// Flip half CTX1 block vertically.
|
||||
inline void BlockCTX1::flip2()
|
||||
{
|
||||
swap(row[0], row[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, BlockDXT1 & block)
|
||||
@ -592,3 +656,9 @@ Stream & nv::operator<<(Stream & stream, BlockATI2 & block)
|
||||
return stream << block.x << block.y;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, BlockCTX1 & block)
|
||||
{
|
||||
stream.serialize(&block, sizeof(block));
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace nv
|
||||
void flip4();
|
||||
void flip2();
|
||||
};
|
||||
|
||||
|
||||
/// ATI2 block.
|
||||
struct BlockATI2
|
||||
{
|
||||
@ -188,6 +188,26 @@ namespace nv
|
||||
void flip2();
|
||||
};
|
||||
|
||||
/// CTX1 block.
|
||||
struct BlockCTX1
|
||||
{
|
||||
uint8 col0[2];
|
||||
uint8 col1[2];
|
||||
union {
|
||||
uint8 row[4];
|
||||
uint indices;
|
||||
};
|
||||
|
||||
void evaluatePalette(Color32 color_array[4]) const;
|
||||
void setIndices(int * idx);
|
||||
|
||||
void decodeBlock(ColorBlock * block) const;
|
||||
|
||||
void flip4();
|
||||
void flip2();
|
||||
};
|
||||
|
||||
|
||||
// Serialization functions.
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT1 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, AlphaBlockDXT3 & block);
|
||||
@ -196,6 +216,7 @@ namespace nv
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT5 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockATI1 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockATI2 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockCTX1 & block);
|
||||
|
||||
} // nv namespace
|
||||
|
||||
|
@ -71,4 +71,4 @@ private:
|
||||
|
||||
} // namespace squish
|
||||
|
||||
#endif // ndef SQUISH_CLUSTERFIT_H
|
||||
#endif // ndef SQUISH_FASTCLUSTERFIT_H
|
||||
|
@ -118,7 +118,13 @@ public:
|
||||
Vec3 copy( left );
|
||||
return copy += right;
|
||||
}
|
||||
|
||||
|
||||
friend Vec3 operator+( Arg left, float right )
|
||||
{
|
||||
Vec3 copy( left );
|
||||
return copy += Vec3(right);
|
||||
}
|
||||
|
||||
friend Vec3 operator-( Arg left, Arg right )
|
||||
{
|
||||
Vec3 copy( left );
|
||||
|
@ -76,8 +76,6 @@ public:
|
||||
void operator+=(Vector3::Arg v);
|
||||
void operator-=(Vector3::Arg v);
|
||||
void operator*=(scalar s);
|
||||
inline void operator/=(scalar s)
|
||||
{ m_x /= s; m_y /= s; m_z /= s; }
|
||||
void operator*=(Vector3::Arg v);
|
||||
|
||||
friend bool operator==(Vector3::Arg a, Vector3::Arg b);
|
||||
|
Loading…
Reference in New Issue
Block a user