From bb4cdeb6928086447b0207ce84a8719d5182dcda Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 14 Apr 2015 21:18:08 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/src/mdsprite.c | 10 ++--- polymer/eduke32/build/src/polymer.c | 65 ++++++++++++++++++---------- polymer/eduke32/build/src/polymost.c | 25 ++++++----- 3 files changed, 60 insertions(+), 40 deletions(-) diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 432d286c4..d61511010 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -2119,19 +2119,19 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr) bglEnable(GL_TEXTURE_2D); + // tinting 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 (!(m->flags&1)) - { hictinting_apply(pc, globalpal); - - if (have_basepal_tint()) - hictinting_apply(pc, MAXPALOOKUPS-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; } else pc[3] = 1.0f; pc[3] *= 1.0f - sext->alpha; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 51b621dd5..ff4975980 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -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); - if (pth && (pth->flags & PTH_HIGHTILE)) + if (pth) { - if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL)) - hictinting_apply(glcolors[i], palnum); + // tinting + 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); } - else if (hictinting[palnum].f & HICTINT_USEONART) - hictinting_apply(glcolors[i], palnum); 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); - if (pth && (pth->flags & PTH_HIGHTILE)) + if (pth) { - if (pth->palnum != palnum || (pth->effects & HICTINT_IN_MEMORY) || (hictinting[palnum].f & HICTINT_APPLYOVERALTPAL)) - hictinting_apply(color, palnum); + // tinting + 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); } - else if (hictinting[palnum].f & HICTINT_USEONART) - hictinting_apply(color, palnum); bglColor4f(color[0], color[1], color[2], 1.0); bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); @@ -4186,8 +4202,7 @@ static void polymer_drawmdsprite(tspritetype *tspr) usinghighpal = (pr_highpalookups && prhighpalookups[curbasepal][tspr->pal].map); - // If that palette has a highpalookup, we'll never use tinting. We might use - // alternate skins if they exist later, though. + // tinting if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED)) { if (!(m->flags&1)) @@ -4195,7 +4210,7 @@ static void polymer_drawmdsprite(tspritetype *tspr) else globalnoeffect=1; //mdloadskin reads this } - // fullscreen tint on global palette change + // global tinting if (!usinghighpal && have_basepal_tint()) hictinting_apply_ub(color, MAXPALOOKUPS-1); @@ -4659,17 +4674,21 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile material->diffusemodulation[2] = (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); - - // 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 if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT) diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 392506a2f..5fc086f4d 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1561,22 +1561,23 @@ static void drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method // spriteext full alpha control pc[3] = float_trans[method & 3] * (1.f - drawpoly_alpha); - // tinting happens only to hightile textures, and only if the texture we're - // rendering isn't for the same palette as what we asked for - - if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED)) + if (pth) { - 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); - - 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) - hictinting_apply(pc, globalpal); + + // global tinting + if ((pth->flags & PTH_HIGHTILE) && have_basepal_tint()) + hictinting_apply(pc, MAXPALOOKUPS-1); } bglColor4f(pc[0], pc[1], pc[2], pc[3]);