When dumping textures, two T1RGB5 texture maps are written: with and without contour processing. Contour processing can be disabled per-polygon and some textures intended to be used without contour processing contain pixels with T=1 that are clearly not supposed to be transparent. We now output textures_t1rgb5_contour.bmp and textures_t1rgb5_opaque.bmp.

This commit is contained in:
Bart Trzynadlowski 2022-02-05 00:52:34 +00:00
parent 32933ef9b0
commit 3f6937e1a6
2 changed files with 55 additions and 42 deletions

View file

@ -1092,8 +1092,10 @@ CReal3D::~CReal3D(void)
// Dump textures if requested
if (m_config["DumpTextures"].ValueAsDefault<bool>(false))
{
Util::WriteSurfaceToBMP<Util::T1RGB5>("textures_t1rgb5.bmp", reinterpret_cast<uint8_t*>(textureRAM), 2048, 2048, false);
printf("Wrote textures as T1RGB5 to 'textures_t1rgb5.bmp'\n");
Util::WriteSurfaceToBMP<Util::T1RGB5ContourEnabled>("textures_t1rgb5_contour.bmp", reinterpret_cast<uint8_t*>(textureRAM), 2048, 2048, false);
printf("Wrote textures as T1RGB5 (contour bit enabled) to 'textures_t1rgb5_contour.bmp'\n");
Util::WriteSurfaceToBMP<Util::T1RGB5ContourIgnored>("textures_t1rgb5_opaque.bmp", reinterpret_cast<uint8_t*>(textureRAM), 2048, 2048, false);
printf("Wrote textures as T1RGB5 (contour bit ignored) to 'textures_t1rgb5_opaque.bmp'\n");
Util::WriteSurfaceToBMP<Util::A4L4Low>("textures_a4l4_lo.bmp", reinterpret_cast<uint8_t*>(textureRAM), 2048, 2048, false);
printf("Wrote textures as A4L4 (low) to 'textures_a4l4_lo.bmp'\n");
Util::WriteSurfaceToBMP<Util::L4A4Low>("textures_l4a4_lo.bmp", reinterpret_cast<uint8_t*>(textureRAM), 2048, 2048, false);

View file

@ -129,6 +129,7 @@ namespace Util
};
// Texture format 0: TRRR RRGG GGGB BBBB, T = contour bit
template <bool EnableContour>
struct T1RGB5
{
static const unsigned bytes_per_pixel = 2;
@ -145,12 +146,22 @@ namespace Util
return uint8_t((255.0f / 31.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 0) & 0x1f));
}
static inline uint8_t GetAlpha(const uint8_t *pixel)
{
if (EnableContour)
{
bool t = (*reinterpret_cast<const uint16_t*>(pixel) >> 15) & 0x1;
return t ? uint8_t(0x00) : uint8_t(0xff); // T-bit indicates transparency
}
else
{
return 0xff; // force opaque
}
}
};
using T1RGB5ContourEnabled = struct T1RGB5<true>;
using T1RGB5ContourIgnored = struct T1RGB5<false>;
// Texture format 1: xxxx xxxx AAAA LLLL
struct A4L4Low
{