- Fixed: COLORMAP tricks to produce bright lights do not work with the hardware renderer, so do

not hardware accelerate weapon sprites that use them. (see Harmony)

SVN r3170 (trunk)
This commit is contained in:
Randy Heit 2011-03-19 04:45:59 +00:00
parent 820554d636
commit 3344fa9f30
5 changed files with 62 additions and 6 deletions

View file

@ -50,6 +50,7 @@
static int R_CountTexturesX ();
static int R_CountLumpTextures (int lumpnum);
static bool R_CheckForFixedLights(const BYTE *colormaps);
extern void R_DeinitBuildTiles();
extern int R_CountBuildTiles();
@ -230,9 +231,58 @@ void R_InitColormaps ()
}
}
NormalLight.Maps = realcolormaps;
NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps);
numfakecmaps = fakecmaps.Size();
}
//==========================================================================
//
// R_CheckForFixedLights
//
// Returns true if there are any entries in the colormaps that are the
// same for every colormap and not the fade color.
//
//==========================================================================
static bool R_CheckForFixedLights(const BYTE *colormaps)
{
const BYTE *lastcolormap = colormaps + (NUMCOLORMAPS - 1) * 256;
BYTE freq[256];
int i, j;
// Count the frequencies of different colors in the final colormap.
// If they occur more than X amount of times, we ignore them as a
// potential fixed light.
memset(freq, 0, sizeof(freq));
for (i = 0; i < 256; ++i)
{
freq[lastcolormap[i]]++;
}
// Now check the colormaps for fixed lights that are uncommon in the
// final coloramp.
for (i = 255; i >= 0; --i)
{
BYTE color = lastcolormap[i];
if (freq[color] > 10) // arbitrary number to decide "common" colors
{
continue;
}
// It's rare in the final colormap. See if it's the same for all colormaps.
for (j = 0; j < NUMCOLORMAPS - 1; ++j)
{
if (colormaps[j * 256 + i] != color)
break;
}
if (j == NUMCOLORMAPS - 1)
{ // It was the same all the way across.
return true;
}
}
return false;
}
//==========================================================================
//
// [RH] Returns an index into realcolormaps. Multiply it by

View file

@ -2301,6 +2301,14 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_
}
}
}
// If the main colormap has fixed lights, and this sprite is being drawn with that
// colormap, disable acceleration so that the lights can remain fixed.
if (!noaccel &&
NormalLightHasFixedLights && mybasecolormap == &NormalLight &&
vis->pic->UseBasePalette())
{
noaccel = true;
}
VisPSpritesBaseColormap[pspnum] = mybasecolormap;
}
else

View file

@ -173,7 +173,7 @@ public:
BYTE bHasCanvas:1; // Texture is based off FCanvasTexture
BYTE bWarped:2; // This is a warped texture. Used to avoid multiple warps on one texture
BYTE bComplex:1; // Will be used to mark extended MultipatchTextures that have to be
// fully composited before subjected to any kinf of postprocessing instead of
// fully composited before subjected to any kind of postprocessing instead of
// doing it per patch.
BYTE bMultiPatch:1; // This is a multipatch texture (we really could use real type info for textures...)

View file

@ -61,6 +61,7 @@
extern "C" {
FDynamicColormap NormalLight;
}
bool NormalLightHasFixedLights;
FPalette GPalette;
TArray<FSpecialColormap> SpecialColormaps;
BYTE DesaturateColormap[31][256];
@ -860,11 +861,7 @@ void FDynamicColormap::ChangeColor (PalEntry lightcolor, int desaturate)
{
Color = lightcolor;
// [BB] desaturate must be in [0,255]
if( desaturate > 255 )
desaturate = 255;
else if ( desaturate < 0 )
desaturate = 0;
Desaturate = desaturate;
Desaturate = clamp(desaturate, 0, 255);
if (Maps) BuildLights ();
}
}

View file

@ -133,6 +133,7 @@ extern FPalette GPalette;
extern "C" {
extern FDynamicColormap NormalLight;
}
extern bool NormalLightHasFixedLights;
// The color overlay to use for depleted items
#define DIM_OVERLAY MAKEARGB(170,0,0,0)