Make all the hictinting_apply blocks consistent. This should fix certain tints types being applied incorrectly in Polymer and the global tints (underwater and nightvision) not being applied to tints and models with certain flags.

git-svn-id: https://svn.eduke32.com/eduke32@5149 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-04-14 21:18:08 +00:00
parent 3a26e5b241
commit bb4cdeb692
3 changed files with 60 additions and 40 deletions

View file

@ -2119,19 +2119,19 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
bglEnable(GL_TEXTURE_2D); bglEnable(GL_TEXTURE_2D);
// tinting
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades); pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED)) if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
{ {
if (!(m->flags&1)) if (!(m->flags&1))
{
hictinting_apply(pc, globalpal); hictinting_apply(pc, globalpal);
if (have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS-1);
}
else globalnoeffect=1; else globalnoeffect=1;
} }
// global tinting
if (have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS-1);
if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66f; else pc[3] = 0.33f; } if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66f; else pc[3] = 0.33f; }
else pc[3] = 1.0f; else pc[3] = 1.0f;
pc[3] *= 1.0f - sext->alpha; pc[3] *= 1.0f - sext->alpha;

View file

@ -3881,16 +3881,24 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
glcolors[i][0] = glcolors[i][1] = glcolors[i][2] = getshadefactor(shade); glcolors[i][0] = glcolors[i][1] = glcolors[i][2] = getshadefactor(shade);
if (pth && (pth->flags & PTH_HIGHTILE)) if (pth)
{ {
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL)) // tinting
hictinting_apply(glcolors[i], palnum); if (!(hictinting[palnum].f & HICTINT_PRECOMPUTED))
{
if (pth->flags & PTH_HIGHTILE)
{
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL))
hictinting_apply(glcolors[i], palnum);
}
else if (hictinting[palnum].f & HICTINT_USEONART)
hictinting_apply(glcolors[i], palnum);
}
if (have_basepal_tint()) // global tinting
if ((pth->flags & PTH_HIGHTILE) && have_basepal_tint())
hictinting_apply(glcolors[i], MAXPALOOKUPS-1); hictinting_apply(glcolors[i], MAXPALOOKUPS-1);
} }
else if (hictinting[palnum].f & HICTINT_USEONART)
hictinting_apply(glcolors[i], palnum);
i++; i++;
} }
@ -3964,16 +3972,24 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
color[0] = color[1] = color[2] = getshadefactor(shade); color[0] = color[1] = color[2] = getshadefactor(shade);
if (pth && (pth->flags & PTH_HIGHTILE)) if (pth)
{ {
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL)) // tinting
hictinting_apply(color, palnum); if (!(hictinting[palnum].f & HICTINT_PRECOMPUTED))
{
if (pth->flags & PTH_HIGHTILE)
{
if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL))
hictinting_apply(color, palnum);
}
else if (hictinting[palnum].f & HICTINT_USEONART)
hictinting_apply(color, palnum);
}
if (have_basepal_tint()) // global tinting
if ((pth->flags & PTH_HIGHTILE) && have_basepal_tint())
hictinting_apply(color, MAXPALOOKUPS-1); hictinting_apply(color, MAXPALOOKUPS-1);
} }
else if (hictinting[palnum].f & HICTINT_USEONART)
hictinting_apply(color, palnum);
bglColor4f(color[0], color[1], color[2], 1.0); bglColor4f(color[0], color[1], color[2], 1.0);
bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
@ -4186,8 +4202,7 @@ static void polymer_drawmdsprite(tspritetype *tspr)
usinghighpal = (pr_highpalookups && usinghighpal = (pr_highpalookups &&
prhighpalookups[curbasepal][tspr->pal].map); prhighpalookups[curbasepal][tspr->pal].map);
// If that palette has a highpalookup, we'll never use tinting. We might use // tinting
// alternate skins if they exist later, though.
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED)) if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED))
{ {
if (!(m->flags&1)) if (!(m->flags&1))
@ -4195,7 +4210,7 @@ static void polymer_drawmdsprite(tspritetype *tspr)
else globalnoeffect=1; //mdloadskin reads this else globalnoeffect=1; //mdloadskin reads this
} }
// fullscreen tint on global palette change // global tinting
if (!usinghighpal && have_basepal_tint()) if (!usinghighpal && have_basepal_tint())
hictinting_apply_ub(color, MAXPALOOKUPS-1); hictinting_apply_ub(color, MAXPALOOKUPS-1);
@ -4659,17 +4674,21 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
material->diffusemodulation[2] = material->diffusemodulation[2] =
(GLubyte)(getshadefactor(shade) * 0xFF); (GLubyte)(getshadefactor(shade) * 0xFF);
if (pth->flags & PTH_HIGHTILE) // tinting
if (!(hictinting[pal].f & HICTINT_PRECOMPUTED))
{ {
if (pth->palnum != pal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[pal].f & HICTINT_APPLYOVERALTPAL)) if (pth->flags & PTH_HIGHTILE)
{
if (pth->palnum != pal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[pal].f & HICTINT_APPLYOVERALTPAL))
hictinting_apply_ub(material->diffusemodulation, pal);
}
else if (hictinting[pal].f & HICTINT_USEONART)
hictinting_apply_ub(material->diffusemodulation, pal); hictinting_apply_ub(material->diffusemodulation, pal);
// fullscreen tint on global palette change... this is used for nightvision and underwater tinting
if (!usinghighpal && have_basepal_tint())
hictinting_apply_ub(material->diffusemodulation, MAXPALOOKUPS-1);
} }
else if (hictinting[pal].f & HICTINT_USEONART)
hictinting_apply_ub(material->diffusemodulation, pal); // global tinting
if ((pth->flags & PTH_HIGHTILE) && !usinghighpal && have_basepal_tint())
hictinting_apply_ub(material->diffusemodulation, MAXPALOOKUPS-1);
// PR_BIT_GLOW_MAP // PR_BIT_GLOW_MAP
if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT) if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT)

View file

@ -1561,22 +1561,23 @@ static void drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method
// spriteext full alpha control // spriteext full alpha control
pc[3] = float_trans[method & 3] * (1.f - drawpoly_alpha); pc[3] = float_trans[method & 3] * (1.f - drawpoly_alpha);
// tinting happens only to hightile textures, and only if the texture we're if (pth)
// rendering isn't for the same palette as what we asked for
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
{ {
if (pth && (pth->flags & PTH_HIGHTILE)) // tinting
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
{ {
if (pth->palnum != globalpal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[globalpal].f & HICTINT_APPLYOVERALTPAL)) if (pth->flags & PTH_HIGHTILE)
{
if (pth->palnum != globalpal || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[globalpal].f & HICTINT_APPLYOVERALTPAL))
hictinting_apply(pc, globalpal);
}
else if (hictinting[globalpal].f & HICTINT_USEONART)
hictinting_apply(pc, globalpal); hictinting_apply(pc, globalpal);
if (have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS-1);
} }
// hack: this is for drawing the 8-bit crosshair recolored in polymost
else if (hictinting[globalpal].f & HICTINT_USEONART) // global tinting
hictinting_apply(pc, globalpal); if ((pth->flags & PTH_HIGHTILE) && have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS-1);
} }
bglColor4f(pc[0], pc[1], pc[2], pc[3]); bglColor4f(pc[0], pc[1], pc[2], pc[3]);