- Added support for defining the full color range of a special colormap.
SVN r1865 (trunk)
This commit is contained in:
parent
79298285f7
commit
84a018f05a
23 changed files with 113 additions and 108 deletions
|
|
@ -66,27 +66,26 @@ BYTE DesaturateColormap[31][256];
|
|||
|
||||
struct FSpecialColormapParameters
|
||||
{
|
||||
float Colorize[3];
|
||||
bool Inverted;
|
||||
float Start[3], End[3];
|
||||
};
|
||||
|
||||
static FSpecialColormapParameters SpecialColormapParms[] =
|
||||
{
|
||||
// Doom invulnerability is an inverted grayscale.
|
||||
// Strife uses it when firing the Sigil
|
||||
{ { 1, 1, 1 }, true },
|
||||
{ { 1, 1, 1 }, { 0, 0, 0 } },
|
||||
|
||||
// Heretic invulnerability is a golden shade.
|
||||
{ { 1.5, 0.75, 0 }, false },
|
||||
{ { 0, 0, 0 }, { 1.5, 0.75, 0 }, },
|
||||
|
||||
// [BC] Build the Doomsphere colormap. It is red!
|
||||
{ { 1.5, 0, 0 }, false },
|
||||
{ { 0, 0, 0 }, { 1.5, 0, 0 } },
|
||||
|
||||
// [BC] Build the Guardsphere colormap. It's a greenish-white kind of thing.
|
||||
{ { 1.25, 1.5, 1 }, false },
|
||||
{ { 0, 0, 0 }, { 1.25, 1.5, 1 } },
|
||||
|
||||
// Build a blue colormap.
|
||||
{ { 0, 0, 1.5 }, false },
|
||||
{{ 0, 0, 0 }, { 0, 0, 1.5 } },
|
||||
};
|
||||
|
||||
static void FreeSpecialLights();
|
||||
|
|
@ -361,14 +360,24 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood)
|
|||
return true;
|
||||
}
|
||||
|
||||
int AddSpecialColormap(double r, double g, double b, bool inv)
|
||||
int AddSpecialColormap(double r1, double g1, double b1, double r2, double g2, double b2)
|
||||
{
|
||||
// Clamp these in range for the hardware shader.
|
||||
r1 = clamp(r1, 0.0, 2.0);
|
||||
g1 = clamp(g1, 0.0, 2.0);
|
||||
b1 = clamp(b1, 0.0, 2.0);
|
||||
r2 = clamp(r2, 0.0, 2.0);
|
||||
g2 = clamp(g2, 0.0, 2.0);
|
||||
b2 = clamp(b2, 0.0, 2.0);
|
||||
|
||||
for(unsigned i=0; i<SpecialColormaps.Size(); i++)
|
||||
{
|
||||
if (SpecialColormaps[i].Colorize[0] == r &&
|
||||
SpecialColormaps[i].Colorize[1] == g &&
|
||||
SpecialColormaps[i].Colorize[2] == b &&
|
||||
SpecialColormaps[i].Inverted == inv)
|
||||
if (SpecialColormaps[i].ColorizeStart[0] == r1 &&
|
||||
SpecialColormaps[i].ColorizeStart[1] == g1 &&
|
||||
SpecialColormaps[i].ColorizeStart[2] == b1 &&
|
||||
SpecialColormaps[i].ColorizeEnd[0] == r2 &&
|
||||
SpecialColormaps[i].ColorizeEnd[1] == g2 &&
|
||||
SpecialColormaps[i].ColorizeEnd[2] == b2)
|
||||
{
|
||||
return i; // The map already exists
|
||||
}
|
||||
|
|
@ -376,35 +385,34 @@ int AddSpecialColormap(double r, double g, double b, bool inv)
|
|||
|
||||
FSpecialColormap *cm = &SpecialColormaps[SpecialColormaps.Reserve(1)];
|
||||
|
||||
cm->Colorize[0] = float(r);
|
||||
cm->Colorize[1] = float(g);
|
||||
cm->Colorize[2] = float(b);
|
||||
cm->Inverted = inv;
|
||||
cm->ColorizeStart[0] = float(r1);
|
||||
cm->ColorizeStart[1] = float(g1);
|
||||
cm->ColorizeStart[2] = float(b1);
|
||||
cm->ColorizeEnd[0] = float(r2);
|
||||
cm->ColorizeEnd[1] = float(g2);
|
||||
cm->ColorizeEnd[2] = float(b2);
|
||||
|
||||
r2 -= r1;
|
||||
g2 -= g1;
|
||||
b2 -= b1;
|
||||
r1 *= 255;
|
||||
g1 *= 255;
|
||||
b1 *= 255;
|
||||
|
||||
for (int c = 0; c < 256; c++)
|
||||
{
|
||||
double intensity = (GPalette.BaseColors[c].r * 77 +
|
||||
GPalette.BaseColors[c].g * 143 +
|
||||
GPalette.BaseColors[c].b * 37) / 256.0;
|
||||
if (inv)
|
||||
{
|
||||
intensity = 255 - intensity;
|
||||
}
|
||||
|
||||
PalEntry pe = PalEntry( MIN(255, int(intensity*r)),
|
||||
MIN(255, int(intensity*g)),
|
||||
MIN(255, int(intensity*b)));
|
||||
PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)),
|
||||
MIN(255, int(g1 + intensity*g2)),
|
||||
MIN(255, int(b1 + intensity*b2)));
|
||||
|
||||
cm->Colormap[c] = ColorMatcher.Pick(pe);
|
||||
|
||||
// This table is used by the texture composition code
|
||||
for(int i = 0;i < 256; i++)
|
||||
{
|
||||
intensity = inv? 255-i : i;
|
||||
cm->GrayscaleToColor[i] = PalEntry( MIN(255, int(intensity*r)),
|
||||
MIN(255, int(intensity*g)),
|
||||
MIN(255, int(intensity*b)));
|
||||
}
|
||||
cm->GrayscaleToColor[c] = pe;
|
||||
}
|
||||
return SpecialColormaps.Size() - 1;
|
||||
}
|
||||
|
|
@ -456,8 +464,9 @@ void InitPalette ()
|
|||
|
||||
for (int i = 0; i < countof(SpecialColormapParms); ++i)
|
||||
{
|
||||
AddSpecialColormap(SpecialColormapParms[i].Colorize[0], SpecialColormapParms[i].Colorize[1],
|
||||
SpecialColormapParms[i].Colorize[2], SpecialColormapParms[i].Inverted);
|
||||
AddSpecialColormap(SpecialColormapParms[i].Start[0], SpecialColormapParms[i].Start[1],
|
||||
SpecialColormapParms[i].Start[2], SpecialColormapParms[i].End[0],
|
||||
SpecialColormapParms[i].End[1], SpecialColormapParms[i].End[2]);
|
||||
}
|
||||
// desaturated colormaps
|
||||
for(int m = 0; m < 31; m++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue