- Added a check to Dehacked code which tries to set the blend color.

It must set it to 0 if the alpha is 0 to avoid problems with special
  colormap detection.
- Changed SPECIALCOLORMAP_MASK again so that it does not interfere with
  any valid setting. It must use a value with a 0-alpha because these
  are guaranteed not to be produced by the DECORATE code elsewhere.
- Fixed precision issues with AddFixedColormap's search for identical colormaps.
- Added custom colormap support to texture composition code.
- Fixed initialization of FSpecialColormap::GrayscaleToColor. This is not
  a mapping from the palette but from a [0,255] grayscale ramp and used to
  apply colormaps to true color images for texture composition.

SVN r1867 (trunk)
This commit is contained in:
Christoph Oelckers 2009-09-22 08:06:52 +00:00
commit 9cc67f565c
6 changed files with 85 additions and 27 deletions

View file

@ -423,19 +423,19 @@ const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spa
BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork)
{
switch (blend.a==0 ? blend.r : -1)
switch (blend.a==0 ? int(blend) : -1)
{
case BLEND_ICEMAP:
return TranslationToTable(TRANSLATION(TRANSLATION_Standard, 7))->Remap;
default:
if (blend.r >= BLEND_SPECIALCOLORMAP1)
if (blend >= BLEND_SPECIALCOLORMAP1)
{
return SpecialColormaps[blend.r - BLEND_SPECIALCOLORMAP1].Colormap;
return SpecialColormaps[blend - BLEND_SPECIALCOLORMAP1].Colormap;
}
else if (blend.r >= BLEND_DESATURATE1 && blend.r <= BLEND_DESATURATE31)
else if (blend >= BLEND_DESATURATE1 && blend <= BLEND_DESATURATE31)
{
return DesaturateColormap[blend.r - BLEND_DESATURATE1];
return DesaturateColormap[blend - BLEND_DESATURATE1];
}
else
{
@ -1048,17 +1048,17 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
match = sc.MatchString(maps);
if (match >= 0)
{
part.Blend.r = BLEND_SPECIALCOLORMAP1 + match;
part.Blend = BLEND_SPECIALCOLORMAP1 + match;
}
else if (sc.Compare("ICE"))
{
part.Blend.r = BLEND_ICEMAP;
part.Blend = BLEND_ICEMAP;
}
else if (sc.Compare("DESATURATE"))
{
sc.MustGetStringName(",");
sc.MustGetNumber();
part.Blend.r = BLEND_DESATURATE1 + clamp(sc.Number-1, 0, 30);
part.Blend = BLEND_DESATURATE1 + clamp(sc.Number-1, 0, 30);
}
else
{
@ -1074,6 +1074,36 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
}
}
else if (sc.Compare("Colormap"))
{
float r1,g1,b1;
float r2,g2,b2;
sc.MustGetFloat();
r1 = (float)sc.Float;
sc.MustGetStringName(",");
sc.MustGetFloat();
g1 = (float)sc.Float;
sc.MustGetStringName(",");
sc.MustGetFloat();
b1 = (float)sc.Float;
if (!sc.CheckString(","))
{
part.Blend = AddSpecialColormap(0,0,0, r1, g1, b1);
}
else
{
sc.MustGetFloat();
r2 = (float)sc.Float;
sc.MustGetStringName(",");
sc.MustGetFloat();
g2 = (float)sc.Float;
sc.MustGetStringName(",");
sc.MustGetFloat();
b2 = (float)sc.Float;
part.Blend = AddSpecialColormap(r1, g1, b1, r2, g2, b2);
}
}
else if (sc.Compare("Blend"))
{
bComplex = true;
@ -1100,10 +1130,14 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
sc.MustGetStringName(",");
part.Blend = MAKERGB(r, g, b);
}
// Blend.a may never be 0 here.
if (sc.CheckString(","))
{
sc.MustGetFloat();
part.Blend.a = clamp<int>(int(sc.Float*255), 1, 254);
if (sc.Float > 0.f)
part.Blend.a = clamp<int>(int(sc.Float*255), 1, 254);
else
part.Blend = 0;
}
else part.Blend.a = 255;
}