mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 15:04:56 +00:00
Various rendering fixes
This commit is contained in:
@@ -1455,7 +1455,8 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
}
|
||||
|
||||
/* Track alpha values for DXT1 eligibility */
|
||||
bool doDXT1 = (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && width >= 4 && height >= 4;
|
||||
bool doDXT = (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && width >= 4 && height >= 4;
|
||||
bool doDXT3 = false;
|
||||
|
||||
/* Read and make RGBA */
|
||||
for (int r = height - 1; r >= 0; --r) {
|
||||
@@ -1499,7 +1500,9 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
bufOut[outbase + 2] = rowBuf[inbase + 2];
|
||||
bufOut[outbase + 3] = rowBuf[inbase + 3];
|
||||
if (rowBuf[inbase + 3] != 0 && rowBuf[inbase + 3] != 255)
|
||||
doDXT1 = false;
|
||||
doDXT = false;
|
||||
else if (rowBuf[inbase + 3] == 0)
|
||||
doDXT3 = true;
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
@@ -1521,7 +1524,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
unsigned filterWidth = width;
|
||||
unsigned filterHeight = height;
|
||||
for (size_t i = 1; i < numMips; ++i) {
|
||||
BoxFilter(filterIn, nComps, filterWidth, filterHeight, filterOut, doDXT1);
|
||||
BoxFilter(filterIn, nComps, filterWidth, filterHeight, filterOut, doDXT);
|
||||
filterIn += filterWidth * filterHeight * nComps;
|
||||
filterWidth /= 2;
|
||||
filterHeight /= 2;
|
||||
@@ -1529,15 +1532,16 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
}
|
||||
}
|
||||
|
||||
/* Do DXT1 compression */
|
||||
/* Do DXT compression */
|
||||
std::unique_ptr<uint8_t[]> compOut;
|
||||
size_t compLen = 0;
|
||||
if (doDXT1) {
|
||||
if (doDXT) {
|
||||
int compFlags = doDXT3 ? squish::kDxt3 : squish::kDxt1;
|
||||
int filterWidth = width;
|
||||
int filterHeight = height;
|
||||
size_t i;
|
||||
for (i = 0; i < numMips; ++i) {
|
||||
compLen += squish::GetStorageRequirements(filterWidth, filterHeight, squish::kDxt1);
|
||||
compLen += squish::GetStorageRequirements(filterWidth, filterHeight, compFlags);
|
||||
if (filterWidth == 4 || filterHeight == 4) {
|
||||
++i;
|
||||
break;
|
||||
@@ -1554,8 +1558,8 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
const uint8_t* rgbaIn = bufOut.get();
|
||||
uint8_t* blocksOut = compOut.get();
|
||||
for (i = 0; i < numMips; ++i) {
|
||||
int thisLen = squish::GetStorageRequirements(filterWidth, filterHeight, squish::kDxt1);
|
||||
squish::CompressImage(rgbaIn, filterWidth, filterHeight, blocksOut, squish::kDxt1);
|
||||
int thisLen = squish::GetStorageRequirements(filterWidth, filterHeight, compFlags);
|
||||
squish::CompressImage(rgbaIn, filterWidth, filterHeight, blocksOut, compFlags);
|
||||
rgbaIn += filterWidth * filterHeight * nComps;
|
||||
blocksOut += thisLen;
|
||||
filterWidth /= 2;
|
||||
@@ -1574,7 +1578,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
|
||||
if (paletteBuf && paletteSize)
|
||||
format = 17;
|
||||
else if (compOut)
|
||||
format = 18;
|
||||
format = doDXT3 ? 19 : 18;
|
||||
else
|
||||
format = 16;
|
||||
outf.writeInt32Big(format);
|
||||
|
||||
Reference in New Issue
Block a user