Account for HICTINT_GRAYSCALE, INVERT, and COLORIZE when applying a tint on 8-bit art.

git-svn-id: https://svn.eduke32.com/eduke32@5145 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-04-14 08:07:41 +00:00
parent 71f576769b
commit 09a26dc24f
3 changed files with 45 additions and 8 deletions

View file

@ -189,7 +189,7 @@ typedef struct pthtyp_t
char skyface;
} pthtyp;
extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t);
extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t);
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char);
extern int32_t globalnoeffect;

View file

@ -799,7 +799,7 @@ static void polymost_setuptexture(const int32_t dameth, int filter)
}
}
void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc)
void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc)
{
static int32_t fullbrightloadingpass = 0;
@ -884,6 +884,35 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth
}
bricolor((palette_t *)wpptr, dacol);
if (!fullbrightloadingpass && tintpalnum >= 0)
{
uint8_t const r = hictinting[tintpalnum].r;
uint8_t const g = hictinting[tintpalnum].g;
uint8_t const b = hictinting[tintpalnum].b;
uint8_t const effect = hictinting[tintpalnum].f;
if (effect & HICTINT_GRAYSCALE)
{
wpptr->g = wpptr->r = wpptr->b = (uint8_t) ((wpptr->r * GRAYSCALE_COEFF_RED) +
(wpptr->g * GRAYSCALE_COEFF_GREEN) +
(wpptr->b * GRAYSCALE_COEFF_BLUE));
}
if (effect & HICTINT_INVERT)
{
wpptr->b = 255 - wpptr->b;
wpptr->g = 255 - wpptr->g;
wpptr->r = 255 - wpptr->r;
}
if (effect & HICTINT_COLORIZE)
{
wpptr->b = min((int32_t)((wpptr->b) * b) >> 6, 255);
wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255);
wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255);
}
}
}
}
}
@ -934,7 +963,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth
pth->ofb = (pthtyp *)Xcalloc(1,sizeof(pthtyp));
pth->flags |= PTH_HASFULLBRIGHT;
gloadtile_art(dapic, dapal, 0, dameth, pth->ofb, 1);
gloadtile_art(dapic, dapal, -1, 0, dameth, pth->ofb, 1);
fullbrightloadingpass = 0;
}

View file

@ -31,13 +31,19 @@ static const char *texcache_errorstr[TEXCACHEERRORS] = {
"bglGetTexLevelParameteriv failed",
};
static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, int32_t const dashade, int32_t const dameth)
{
const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
pthtyp *pth;
int32_t tintpalnum = -1;
int32_t searchpalnum = dapalnum;
if ((hictinting[dapalnum].f & HICTINT_USEONART) && !(hictinting[dapalnum].f & HICTINT_APPLYOVERPALSWAP))
dapalnum = 0;
if (hictinting[dapalnum].f & HICTINT_USEONART)
{
tintpalnum = dapalnum;
if (!(hictinting[dapalnum].f & HICTINT_APPLYOVERPALSWAP))
searchpalnum = 0;
}
// load from art
for (pth=texcache.list[j]; pth; pth=pth->next)
@ -49,7 +55,8 @@ static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dasha
if (pth->flags & PTH_INVALIDATED)
{
pth->flags &= ~PTH_INVALIDATED;
gloadtile_art(dapicnum, dapalnum, dashade, dameth, pth, 0);
gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 0);
pth->palnum = dapalnum;
}
return(pth);
@ -57,8 +64,9 @@ static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dasha
pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp));
gloadtile_art(dapicnum,dapalnum,dashade,dameth,pth,1);
gloadtile_art(dapicnum, searchpalnum, tintpalnum, dashade, dameth, pth, 1);
pth->palnum = dapalnum;
pth->next = texcache.list[j];
texcache.list[j] = pth;