dontencoreremap flag + colormaps

This commit is contained in:
Latapostrophe 2019-11-12 00:40:25 +01:00
parent 3bd62175f6
commit aab87012df
3 changed files with 56 additions and 13 deletions

View file

@ -5762,7 +5762,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
{
vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)))
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
#endif
}
@ -5880,7 +5880,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap)
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
#endif

View file

@ -1407,11 +1407,12 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum)
P_LoadRawSideDefs(W_LumpLength(lumpnum));
}
static void P_LoadRawSideDefs2(void *data)
{
UINT16 i;
INT32 num;
size_t j;
UINT32 cr, cg, cb;
for (i = 0; i < numsides; i++)
{
@ -1490,16 +1491,43 @@ static void P_LoadRawSideDefs2(void *data)
{
col = msd->toptexture;
sec->extra_colormap->rgba =
(HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) +
(HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) +
(HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
// encore mode colormaps!
// do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code.
// do this for both the start and fade colormaps.
cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0);
cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8);
cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
#ifdef GLENCORE
if (encoremap)
{
j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)];
//CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation
cr = pLocalPalette[j].s.red;
cg = pLocalPalette[j].s.green;
cb = pLocalPalette[j].s.blue;
}
#endif
sec->extra_colormap->rgba = cr + cg + cb;
// alpha
if (msd->toptexture[7])
sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24);
else
sec->extra_colormap->rgba += (25 << 24);
/*nearest = NearestColor(
(HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0),
(HEX2INT(col[3]) << 4) + (HEX2INT(col[4]) << 0),
(HEX2INT(col[5]) << 4) + (HEX2INT(col[6]) << 0)
);
sec->extra_colormap->rgba =
pLocalPalette[nearest].s.red +
(pLocalPalette[nearest].s.green << 8) +
(pLocalPalette[nearest].s.blue << 16);*/
}
else
sec->extra_colormap->rgba = 0;
@ -1508,10 +1536,24 @@ static void P_LoadRawSideDefs2(void *data)
{
col = msd->bottomtexture;
sec->extra_colormap->fadergba =
(HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) +
(HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) +
(HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
// do the exact same thing as above here.
cr = (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0);
cg = (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8);
cb = (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16);
#ifdef GLENCORE
if (encoremap)
{
j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)];
//CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation
cr = pLocalPalette[j].s.red;
cg = pLocalPalette[j].s.green;
cb = pLocalPalette[j].s.blue;
}
#endif
sec->extra_colormap->fadergba = cr + cg + cb;
// alpha
if (msd->bottomtexture[7])
@ -1658,6 +1700,7 @@ static void P_LoadRawSideDefs2(void *data)
R_ClearTextureNumCache(true);
}
// Delay loading texture names until after loaded linedefs.
static void P_LoadSideDefs2(lumpnum_t lumpnum)
{

View file

@ -1177,7 +1177,7 @@ void R_ClearColormaps(void)
//
static double deltas[256][3], map[256][3];
static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
static int RoundUp(double number);
#ifdef HASINVERT
@ -1403,7 +1403,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
// Thanks to quake2 source!
// utils3/qdata/images.c
static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b)
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b)
{
int dr, dg, db;
int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i;