- adjustments and fixes for alphatextures:

* Instead of using the red channel it now uses the grayscale value. While slower in a few situations, it is also more precise and makes the feature more useful.
* For paletted textures do not use the index as alpha anymore but the actual grayscaled color. This is again to make the feature more consistent and useful.
* To compensate for the above there is now a list of hashes for known alpha textures in patch format, so that they don't get broken.
* IMGZ is now considered a grayscale format. There's only two known textures that use IMGZ for something else than crosshairs and those are explicitly handled.
* several smaller fixes.
* the actual color conversion functions for paletted output are now consolidated in a small number of inlines so that future changes are easier to do.

Note: This hasn't been tested yet and will need further changes in the hardware rendering code. As it is it is not production-ready.
This commit is contained in:
Christoph Oelckers 2018-03-22 00:29:01 +01:00
commit b473838627
18 changed files with 220 additions and 104 deletions

View file

@ -389,10 +389,9 @@ uint8_t *FPCXTexture::MakeTexture(FRenderStyle style)
{
if (bitcount < 8)
{
for (int i=0;i<16;i++)
for (int i = 0; i < 16; i++)
{
if (!alphatex) PaletteMap[i] = ColorMatcher.Pick(header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
else PaletteMap[i] = header.palette[i * 3];
PaletteMap[i] = RGBToPalettePrecise(alphatex, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
}
switch (bitcount)
@ -418,7 +417,7 @@ uint8_t *FPCXTexture::MakeTexture(FRenderStyle style)
uint8_t r = lump.ReadUInt8();
uint8_t g = lump.ReadUInt8();
uint8_t b = lump.ReadUInt8();
PaletteMap[i] = !alphatex? ColorMatcher.Pick(r,g,b) : r;
PaletteMap[i] = RGBToPalettePrecise(alphatex, r, g, b);
}
lump.Seek(sizeof(header), FileReader::SeekSet);
ReadPCX8bits (Pixels, lump, &header);
@ -445,7 +444,7 @@ uint8_t *FPCXTexture::MakeTexture(FRenderStyle style)
{
for(int x=0; x < Width; x++)
{
Pixels[y + Height * x] = !alphatex? RGB256k.RGB[row[0] >> 2][row[1] >> 2][row[2] >> 2] : row[0];
Pixels[y + Height * x] = RGBToPalette(alphatex, row[0], row[1], row[2]);
row+=3;
}
}