2016-03-01 15:47:10 +00:00
|
|
|
#ifndef __RES_CMAP_H
|
|
|
|
#define __RES_CMAP_H
|
|
|
|
|
2017-03-15 16:14:40 +00:00
|
|
|
#include "m_fixed.h"
|
|
|
|
|
2016-09-14 10:28:39 +00:00
|
|
|
struct FSWColormap;
|
2017-03-15 15:47:42 +00:00
|
|
|
struct lightlist_t;
|
2016-06-05 12:08:03 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
void R_InitColormaps ();
|
|
|
|
void R_DeinitColormaps ();
|
|
|
|
|
2017-03-09 19:19:55 +00:00
|
|
|
uint32_t R_ColormapNumForName(const char *name); // killough 4/4/98
|
2016-03-01 15:47:10 +00:00
|
|
|
void R_SetDefaultColormap (const char *name); // [RH] change normal fadetable
|
2017-03-09 19:19:55 +00:00
|
|
|
uint32_t R_BlendForColormap (uint32_t map); // [RH] return calculated blend for a colormap
|
2016-09-14 08:03:39 +00:00
|
|
|
extern FSWColormap realcolormaps; // [RH] make the colormaps externally visible
|
2016-03-01 15:47:10 +00:00
|
|
|
extern size_t numfakecmaps;
|
|
|
|
|
2017-03-15 15:47:42 +00:00
|
|
|
// for internal use
|
|
|
|
struct FColormap
|
|
|
|
{
|
|
|
|
PalEntry LightColor; // a is saturation (0 full, 31=b/w, other=custom colormap)
|
|
|
|
PalEntry FadeColor; // a is fadedensity>>1
|
|
|
|
uint8_t Desaturation;
|
|
|
|
uint8_t BlendFactor; // This is for handling Legacy-style colormaps which use a different formula to calculate how the color affects lighting.
|
|
|
|
uint16_t FogDensity;
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
LightColor = 0xffffff;
|
|
|
|
FadeColor = 0;
|
|
|
|
Desaturation = 0;
|
|
|
|
BlendFactor = 0;
|
|
|
|
FogDensity = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MakeWhite()
|
|
|
|
{
|
|
|
|
LightColor = 0xffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearColor()
|
|
|
|
{
|
|
|
|
LightColor = 0xffffff;
|
|
|
|
BlendFactor = 0;
|
|
|
|
Desaturation = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyLight(FColormap &from)
|
|
|
|
{
|
|
|
|
LightColor = from.LightColor;
|
|
|
|
Desaturation = from.Desaturation;
|
|
|
|
BlendFactor = from.BlendFactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyFog(FColormap &from)
|
|
|
|
{
|
|
|
|
FadeColor = from.FadeColor;
|
|
|
|
FogDensity = from.FogDensity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyFrom3DLight(lightlist_t *light);
|
|
|
|
|
|
|
|
void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark.
|
|
|
|
{
|
|
|
|
int v = (LightColor.r + LightColor.g + LightColor.b) / 3;
|
|
|
|
LightColor.r = LightColor.g = LightColor.b = (255 + v + v) / 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator == (const FColormap &other)
|
|
|
|
{
|
|
|
|
return LightColor == other.LightColor && FadeColor == other.FadeColor && Desaturation == other.Desaturation &&
|
|
|
|
BlendFactor == other.BlendFactor && FogDensity == other.FogDensity;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator != (const FColormap &other)
|
|
|
|
{
|
|
|
|
return !operator==(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-09-14 08:03:39 +00:00
|
|
|
struct FSWColormap
|
2016-06-05 12:08:03 +00:00
|
|
|
{
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t *Maps = nullptr;
|
2016-06-05 12:08:03 +00:00
|
|
|
PalEntry Color = 0xffffffff;
|
|
|
|
PalEntry Fade = 0xff000000;
|
|
|
|
int Desaturate = 0;
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-14 08:03:39 +00:00
|
|
|
struct FDynamicColormap : FSWColormap
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
void ChangeFade (PalEntry fadecolor);
|
|
|
|
void ChangeColor (PalEntry lightcolor, int desaturate);
|
|
|
|
void ChangeColorFade (PalEntry lightcolor, PalEntry fadecolor);
|
2016-12-29 00:12:17 +00:00
|
|
|
void ChangeFogDensity(int newdensity);
|
2016-03-01 15:47:10 +00:00
|
|
|
void BuildLights ();
|
|
|
|
static void RebuildAllLights();
|
|
|
|
|
|
|
|
FDynamicColormap *Next;
|
|
|
|
};
|
|
|
|
|
2017-03-15 15:47:42 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
// For hardware-accelerated weapon sprites in colored sectors
|
|
|
|
struct FColormapStyle
|
|
|
|
{
|
|
|
|
PalEntry Color;
|
|
|
|
PalEntry Fade;
|
|
|
|
int Desaturate;
|
|
|
|
float FadeLevel;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NOFIXEDCOLORMAP = -1,
|
|
|
|
INVERSECOLORMAP, // the inverse map is used explicitly in a few places.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-14 08:03:39 +00:00
|
|
|
struct FSpecialColormap : FSWColormap
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-06-05 12:08:03 +00:00
|
|
|
FSpecialColormap()
|
|
|
|
{
|
|
|
|
Maps = Colormap;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
float ColorizeStart[3];
|
|
|
|
float ColorizeEnd[3];
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t Colormap[256];
|
2016-03-01 15:47:10 +00:00
|
|
|
PalEntry GrayscaleToColor[256];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern TArray<FSpecialColormap> SpecialColormaps;
|
|
|
|
|
|
|
|
// some utility functions to store special colormaps in powerup blends
|
|
|
|
#define SPECIALCOLORMAP_MASK 0x00b60000
|
|
|
|
|
2017-03-09 18:31:45 +00:00
|
|
|
inline uint32_t MakeSpecialColormap(int index)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
assert(index >= 0 && index < 65536);
|
|
|
|
return index | SPECIALCOLORMAP_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int AddSpecialColormap(float r1, float g1, float b1, float r2, float g2, float b2);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-09 18:54:41 +00:00
|
|
|
extern uint8_t DesaturateColormap[31][256];
|
2016-03-01 15:47:10 +00:00
|
|
|
extern FDynamicColormap NormalLight;
|
2016-10-19 06:02:37 +00:00
|
|
|
extern FDynamicColormap FullNormalLight;
|
2016-03-01 15:47:10 +00:00
|
|
|
extern bool NormalLightHasFixedLights;
|
|
|
|
|
|
|
|
FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate);
|
|
|
|
|
2017-03-15 16:14:40 +00:00
|
|
|
__forceinline FDynamicColormap *GetColorTable(const FColormap &cm)
|
2017-03-15 15:47:42 +00:00
|
|
|
{
|
2017-03-15 16:14:40 +00:00
|
|
|
auto p = &NormalLight;
|
|
|
|
if (cm.LightColor == p->Color &&
|
|
|
|
cm.FadeColor == p->Fade &&
|
|
|
|
cm.Desaturation == p->Desaturate)
|
|
|
|
{
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2017-03-15 15:47:42 +00:00
|
|
|
return GetSpecialLights(cm.LightColor, cm.FadeColor, cm.Desaturation);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#endif
|