mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: imagelib: allow specifiying index for empty pixels when processing luma texture
This commit is contained in:
@@ -85,6 +85,7 @@ typedef struct imglib_s
|
||||
uint *d_currentpal; // installed version of internal palette
|
||||
int d_rendermode; // palette rendermode
|
||||
byte *palette; // palette pointer
|
||||
int black_pixel; // "free" index used for luma textures (0 for Quake as it's black, 255 for Half-Life as it's #0000FF)
|
||||
|
||||
// global parms
|
||||
rgba_t fogParams; // some water textures has info about underwater fog
|
||||
|
||||
@@ -142,6 +142,7 @@ void Image_Reset( void )
|
||||
image.fogParams[1] = 0;
|
||||
image.fogParams[2] = 0;
|
||||
image.fogParams[3] = 0;
|
||||
image.black_pixel = 0;
|
||||
|
||||
// pointers will be saved with prevoius picture struct
|
||||
// don't care about it
|
||||
|
||||
@@ -616,7 +616,7 @@ qboolean Image_Copy8bitRGBA( const byte *in, byte *out, int pixels )
|
||||
if( image.flags & IMAGE_HAS_LUMA )
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
fin[i] = fin[i] < 224 ? fin[i] : 0;
|
||||
fin[i] = fin[i] < 224 ? fin[i] : image.black_pixel;
|
||||
}
|
||||
|
||||
// check for color
|
||||
@@ -1204,7 +1204,7 @@ static byte *Image_MakeLuma( byte *fin, int width, int height, int type, int fla
|
||||
case PF_INDEXED_32:
|
||||
out = image.tempbuffer = Mem_Realloc( host.imagepool, image.tempbuffer, width * height );
|
||||
for( i = 0; i < width * height; i++ )
|
||||
*out++ = fin[i] >= 224 ? fin[i] : 0;
|
||||
*out++ = fin[i] >= 224 ? fin[i] : image.black_pixel;
|
||||
break;
|
||||
default:
|
||||
// another formats does ugly result :(
|
||||
|
||||
@@ -430,7 +430,8 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
{
|
||||
if( fin[i] > 224 )
|
||||
{
|
||||
image.flags |= IMAGE_HAS_LUMA;
|
||||
SetBits( image.flags, IMAGE_HAS_LUMA );
|
||||
image.black_pixel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -464,15 +465,15 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
hl_texture = false;
|
||||
|
||||
// check for luma and alpha pixels
|
||||
if( !image.custom_palette )
|
||||
// don't apply luma to water surfaces because they have no lightmap
|
||||
if( !image.custom_palette && mip.name[0] != '*' && mip.name != '!' )
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
if( fin[i] > 224 && fin[i] != 255 )
|
||||
{
|
||||
// don't apply luma to water surfaces because they have no lightmap
|
||||
if( mip.name[0] != '*' && mip.name[0] != '!' )
|
||||
image.flags |= IMAGE_HAS_LUMA;
|
||||
SetBits( image.flags, IMAGE_HAS_LUMA );
|
||||
image.black_pixel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user