diff --git a/polymer/eduke32/build/include/hightile.h b/polymer/eduke32/build/include/hightile.h index 65482754b..53370f021 100644 --- a/polymer/eduke32/build/include/hightile.h +++ b/polymer/eduke32/build/include/hightile.h @@ -90,7 +90,16 @@ enum HICTINT_APPLYOVERPALSWAP = 16, HICTINT_APPLYOVERALTPAL = 32, - HICEFFECTMASK = (1|2|4|8|16|32), + HICTINT_BLEND_MULTIPLY = 0<<6, + HICTINT_BLEND_SCREEN = 1<<6, + HICTINT_BLEND_OVERLAY = 2<<6, + HICTINT_BLEND_HARDLIGHT = 3<<6, + + HICTINT_BLENDMASK = 64|128, + + HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK, + + HICEFFECTMASK = 255, // XXX: Xcalloc() based on this value, why? }; #define GRAYSCALE_COEFF_RED 0.3 diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index e753d64b0..432d286c4 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -654,6 +654,25 @@ static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t tcol.r = min((int32_t)(tcol.r)*r/64,255); } + switch (effect & HICTINT_BLENDMASK) + { + case HICTINT_BLEND_SCREEN: + tcol.b = 255 - (((255 - tcol.b) * (255 - b)) >> 8); + tcol.g = 255 - (((255 - tcol.g) * (255 - g)) >> 8); + tcol.r = 255 - (((255 - tcol.r) * (255 - r)) >> 8); + break; + case HICTINT_BLEND_OVERLAY: + tcol.b = tcol.b < 128 ? (tcol.b * b) >> 7 : 255 - (((255 - tcol.b) * (255 - b)) >> 7); + tcol.g = tcol.g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7); + tcol.r = tcol.r < 128 ? (tcol.r * r) >> 7 : 255 - (((255 - tcol.r) * (255 - r)) >> 7); + break; + case HICTINT_BLEND_HARDLIGHT: + tcol.b = b < 128 ? (tcol.b * b) >> 7 : 255 - (((255 - tcol.b) * (255 - b)) >> 7); + tcol.g = g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7); + tcol.r = r < 128 ? (tcol.r * r) >> 7 : 255 - (((255 - tcol.r) * (255 - r)) >> 7); + break; + } + rpptr[x].b = tcol.b; rpptr[x].g = tcol.g; rpptr[x].r = tcol.r; @@ -2101,7 +2120,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr) bglEnable(GL_TEXTURE_2D); pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades); - if (!(hictinting[globalpal].f & HICTINT_COLORIZE)) + if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED)) { if (!(m->flags&1)) { diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index a6b2015bc..1d2ec32b2 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -4188,7 +4188,7 @@ static void polymer_drawmdsprite(tspritetype *tspr) // If that palette has a highpalookup, we'll never use tinting. We might use // alternate skins if they exist later, though. - if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_COLORIZE)) + if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED)) { if (!(m->flags&1)) hictinting_apply_ub(color, tspr->pal); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 98f082d92..3a8d0b7e8 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -912,6 +912,25 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255); wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255); } + + switch (effect & HICTINT_BLENDMASK) + { + case HICTINT_BLEND_SCREEN: + wpptr->b = 255 - (((255 - wpptr->b) * (255 - b)) >> 8); + wpptr->g = 255 - (((255 - wpptr->g) * (255 - g)) >> 8); + wpptr->r = 255 - (((255 - wpptr->r) * (255 - r)) >> 8); + break; + case HICTINT_BLEND_OVERLAY: + wpptr->b = wpptr->b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7); + wpptr->g = wpptr->g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7); + wpptr->r = wpptr->r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7); + break; + case HICTINT_BLEND_HARDLIGHT: + wpptr->b = b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7); + wpptr->g = g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7); + wpptr->r = r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7); + break; + } } } } @@ -1136,6 +1155,25 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp tcol.r = min((int32_t)((tcol.r) * b) >> 6, 255); } + switch (effect & HICTINT_BLENDMASK) + { + case HICTINT_BLEND_SCREEN: + tcol.b = 255 - (((255 - tcol.b) * (255 - r)) >> 8); + tcol.g = 255 - (((255 - tcol.g) * (255 - g)) >> 8); + tcol.r = 255 - (((255 - tcol.r) * (255 - b)) >> 8); + break; + case HICTINT_BLEND_OVERLAY: + tcol.b = tcol.b < 128 ? (tcol.b * r) >> 7 : 255 - (((255 - tcol.b) * (255 - r)) >> 7); + tcol.g = tcol.g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7); + tcol.r = tcol.r < 128 ? (tcol.r * b) >> 7 : 255 - (((255 - tcol.r) * (255 - b)) >> 7); + break; + case HICTINT_BLEND_HARDLIGHT: + tcol.b = r < 128 ? (tcol.b * r) >> 7 : 255 - (((255 - tcol.b) * (255 - r)) >> 7); + tcol.g = g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7); + tcol.r = b < 128 ? (tcol.r * b) >> 7 : 255 - (((255 - tcol.r) * (255 - b)) >> 7); + break; + } + rpptr[x] = tcol; } } @@ -1526,7 +1564,7 @@ static void drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method // 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_COLORIZE)) + if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED)) { if (pth && (pth->flags & PTH_HIGHTILE)) {