2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-29 12:15:26 +01:00

engine: imagelib: add LUMP_TEXGAMMA palette kind to only pass HL textures through texgamma, not Quake

This commit is contained in:
Alibek Omarov 2024-07-19 06:34:48 +03:00
parent 42a915b04a
commit 85dfaaa2c2
3 changed files with 30 additions and 10 deletions

View File

@ -108,12 +108,13 @@ typedef struct imglib_s
enum
{
LUMP_NORMAL = 0, // no alpha
LUMP_MASKED, // 1-bit alpha channel masked texture
LUMP_GRADIENT, // gradient image (decals)
LUMP_EXTENDED, // bmp images have extened palette with alpha-channel
LUMP_HALFLIFE, // get predefined half-life palette
LUMP_QUAKE1 // get predefined quake palette
LUMP_NORMAL = 0, // no alpha
LUMP_MASKED, // 1-bit alpha channel masked texture
LUMP_GRADIENT, // gradient image (decals)
LUMP_EXTENDED, // bmp images have extened palette with alpha-channel
LUMP_HALFLIFE, // get predefined half-life palette
LUMP_QUAKE1, // get predefined quake palette
LUMP_TEXGAMMA, // apply texgamma on top of palette, for half-life mips
};
enum

View File

@ -293,9 +293,18 @@ static void Image_SetPalette( const byte *pal, uint *d_table )
case LUMP_NORMAL:
for( i = 0; i < 256; i++ )
{
rgba[0] = TextureToGamma( pal[i*3+0] );
rgba[1] = TextureToGamma( pal[i*3+1] );
rgba[2] = TextureToGamma( pal[i*3+2] );
memcpy( rgba, &pal[i * 3], 3 );
rgba[3] = 0xFF;
memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;
}
break;
case LUMP_TEXGAMMA:
for( i = 0; i < 256; i++ )
{
rgba[0] = TextureToGamma( pal[i * 3 + 0] );
rgba[1] = TextureToGamma( pal[i * 3 + 1] );
rgba[2] = TextureToGamma( pal[i * 3 + 2] );
rgba[3] = 0xFF;
memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba;

View File

@ -427,8 +427,18 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
}
if( pal_type == PAL_QUAKE1 )
{
SetBits( image.flags, IMAGE_QUAKEPAL );
rendermode = LUMP_NORMAL;
// if texture was converted from quake to half-life with no palette changes
// then applying texgamma might make it too dark or even outright broken
rendermode = LUMP_NORMAL;
}
else
{
// half-life mips need texgamma applied
rendermode = LUMP_TEXGAMMA;
}
}
Image_GetPaletteLMP( pal, rendermode );